From b899cfb6a5b58a8cf4e22bd2eea069c4fe4121c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Smodi=C5=A1?= Date: Mon, 5 Oct 2015 20:13:08 +0200 Subject: Add the prolog runner to be used for daemonisation in init scripts. --- prolog/runner/daemon.pl | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 prolog/runner/daemon.pl diff --git a/prolog/runner/daemon.pl b/prolog/runner/daemon.pl new file mode 100755 index 0000000..b079d94 --- /dev/null +++ b/prolog/runner/daemon.pl @@ -0,0 +1,25 @@ +#!/usr/bin/swipl -q --nosignals -tty -s + +% Pengine and HTTP server modules. +:- use_module(library(http/http_dispatch)). +:- use_module(library(http/http_error)). +:- use_module(library(http/thread_httpd)). +:- use_module(library(http/http_unix_daemon)). +:- use_module(library(pengines)). +:- use_module(library(pengines_io)). + +:- use_module(library(clpfd)). +:- use_module(library(clpr)). + +:- consult(sandbox). + +:- multifile prolog:error_message/3. +prolog:error_message(time_limit_exceeded) --> + [ 'time limit exceeded' ]. + +:- set_setting(pengine_sandbox:time_limit, 5.0). +:- set_setting(pengine_sandbox:thread_pool_size, 50). + +% Start the server. Set fork(true) if you desire for the process to fork into background. You may also want pidfile(filename). +% See /usr/lib/swi-prolog/library/http/http_unix_daemon.pl and thread_httpd.pl for all options. +:- http_daemon([port(3030), ip(localhost), fork(false), workers(10), timeout(30), keep_alive_timeout(30), user(nobody), group(nogroup)]). -- cgit v1.2.1 From e61c812f5f652c87cae76bdd155249cda14dcdff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Smodi=C5=A1?= Date: Mon, 5 Oct 2015 21:27:39 +0200 Subject: Implemented systemd unit files to manage CodeQ daemons. --- scripts/systemd/codeq | 10 ++++++++++ scripts/systemd/codeq-prolog.service | 13 +++++++++++++ scripts/systemd/codeq-server.service | 15 +++++++++++++++ scripts/systemd/codeq-web.service | 15 +++++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 scripts/systemd/codeq create mode 100644 scripts/systemd/codeq-prolog.service create mode 100644 scripts/systemd/codeq-server.service create mode 100644 scripts/systemd/codeq-web.service diff --git a/scripts/systemd/codeq b/scripts/systemd/codeq new file mode 100644 index 0000000..83a4e6c --- /dev/null +++ b/scripts/systemd/codeq @@ -0,0 +1,10 @@ +# /etc/default/codeq, common settings for CodeQ programs +CODEQ_PROBLEMS=/var/local/codeq-problems +CODEQ_WEB_OUTPUT=/var/www/html/data +CODEQ_DB_HOST=localhost +CODEQ_DB_DATABASE=codeq +CODEQ_DB_USER=codeq +CODEQ_DB_PASS=c0d3q +CODEQ_SERVER_LOG=/var/log/codeq-server.log +CODEQ_WEB_LOG=/var/log/codeq-web.log + diff --git a/scripts/systemd/codeq-prolog.service b/scripts/systemd/codeq-prolog.service new file mode 100644 index 0000000..0c9abdb --- /dev/null +++ b/scripts/systemd/codeq-prolog.service @@ -0,0 +1,13 @@ +# /etc/systemd/system/codeq-prolog.service +[Unit] +After=network.target +Description=CodeQ Prolog daemon + +[Service] +ExecStart=/usr/bin/swipl -q --nosignals -tty -s /var/local/codeq-server/prolog/runner/daemon.pl +Restart=on-failure +Type=simple +StandardInput=null +StandardOutput=null +StandardError=null + diff --git a/scripts/systemd/codeq-server.service b/scripts/systemd/codeq-server.service new file mode 100644 index 0000000..26e05f9 --- /dev/null +++ b/scripts/systemd/codeq-server.service @@ -0,0 +1,15 @@ +# /etc/systemd/system/codeq-server.service +[Unit] +Wants=postgresql.service codeq-prolog.service +After=network.target postgresql.service codeq-prolog.service +Description=CodeQ server + +[Service] +ExecStart=/usr/bin/python3 /var/local/codeq-server/daemon.py +Restart=on-failure +Type=simple +StandardInput=null +StandardOutput=null +StandardError=null +EnvironmentFile=-/etc/default/codeq + diff --git a/scripts/systemd/codeq-web.service b/scripts/systemd/codeq-web.service new file mode 100644 index 0000000..92d2076 --- /dev/null +++ b/scripts/systemd/codeq-web.service @@ -0,0 +1,15 @@ +# /etc/systemd/system/codeq-web.service +[Unit] +Wants=codeq-server.service +After=network.target codeq-server.service +Description=CodeQ web services + +[Service] +ExecStart=/usr/bin/nodejs /var/local/codeq-server/web/main.js +Restart=on-failure +Type=simple +StandardInput=null +StandardOutput=null +StandardError=null +EnvironmentFile=-/etc/default/codeq + -- cgit v1.2.1