diff --git a/conf/settings.ini.dist b/conf/settings.ini.dist index 8947e9e..f5e3f8d 100644 --- a/conf/settings.ini.dist +++ b/conf/settings.ini.dist @@ -64,3 +64,6 @@ ;listen_ip = '127.0.0.1' ; Port used by the hypnotoad daemon ;listen_port = '8090' +; server backend. Can be either morbo (DEV) or hypnotoad (PROD) +; default is hypnotoad +;backend = 'hypnotoad' diff --git a/docs/systemd/vroom.service b/docs/systemd/vroom.service index f66bdb7..1aa3c53 100644 --- a/docs/systemd/vroom.service +++ b/docs/systemd/vroom.service @@ -4,8 +4,7 @@ After=mariadb.service [Service] Type=simple -ExecStart=/opt/vroom/scripts/start_hypnotoad -PIDFile=/tmp/vroom.pid +ExecStart=/opt/vroom/scripts/start_server.pl PrivateTmp=yes User=apache Group=apache diff --git a/scripts/start_hypnotoad b/scripts/start_hypnotoad deleted file mode 100755 index 3532cdc..0000000 --- a/scripts/start_hypnotoad +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -DIR=$(dirname $0) -export PERL5LIB="$DIR/../lib/" -cd $DIR/.. -hypnotoad -f vroom.pl "$*" diff --git a/scripts/start_server.pl b/scripts/start_server.pl new file mode 100755 index 0000000..6f57452 --- /dev/null +++ b/scripts/start_server.pl @@ -0,0 +1,26 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use Config::Simple; +use File::Basename; + +my $dir=dirname($0); +chdir $dir . '/..'; + +my $cfg = new Config::Simple(); +$cfg->read('conf/settings.ini'); +our $config = $cfg->vars(); + +$config->{'daemon.listen_ip'} ||= '127.0.0.1'; +$config->{'daemon.listen_port'} ||= '8090'; +$config->{'daemon.backend'} ||= 'hypnotoad'; + +$ENV{'PERL5LIB'} = 'lib'; + +if ($config->{'daemon.backend'} eq 'morbo'){ + exec ('/usr/bin/morbo', '-l', 'http://' . $config->{'daemon.listen_ip'} . ':' . $config->{'daemon.listen_port'}, '-v', 'vroom.pl'); +} +else{ + exec ('/usr/bin/hypnotoad', '-f', 'vroom.pl'); +}