From 918065abd203566316236a9529d08b2acb169543 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 13 Oct 2014 19:56:19 +0200 Subject: [PATCH] Alter startup script to be able to choose between morbo and hypnotoad --- conf/settings.ini.dist | 3 +++ docs/systemd/vroom.service | 3 +-- scripts/start_hypnotoad | 6 ------ scripts/start_server.pl | 26 ++++++++++++++++++++++++++ 4 files changed, 30 insertions(+), 8 deletions(-) delete mode 100755 scripts/start_hypnotoad create mode 100755 scripts/start_server.pl 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'); +}