From 146d1b7881d8097d46acd0ab22f5a7a63d7f19cc Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Sun, 12 Oct 2014 18:22:02 +0200 Subject: [PATCH] Adapt to run vroom under hypnotoad instead of a CGI script Fix #83 --- docs/systemd/vroom.service | 16 ++++++++++++++++ scripts/start_hypnotoad | 6 ++++++ templates/default/header.html.ep | 2 +- templates/default/js_common.html.ep | 2 +- templates/default/js_room.html.ep | 2 +- public/vroom.pl => vroom.pl | 14 +++++++++++--- 6 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 docs/systemd/vroom.service create mode 100755 scripts/start_hypnotoad rename public/vroom.pl => vroom.pl (99%) diff --git a/docs/systemd/vroom.service b/docs/systemd/vroom.service new file mode 100644 index 0000000..f66bdb7 --- /dev/null +++ b/docs/systemd/vroom.service @@ -0,0 +1,16 @@ +[Unit] +Description=VROOM daemon +After=mariadb.service + +[Service] +Type=simple +ExecStart=/opt/vroom/scripts/start_hypnotoad +PIDFile=/tmp/vroom.pid +PrivateTmp=yes +User=apache +Group=apache + +[Install] +WantedBy=multi-user.target +Wants=mariadb.service httpd.service + diff --git a/scripts/start_hypnotoad b/scripts/start_hypnotoad new file mode 100755 index 0000000..3532cdc --- /dev/null +++ b/scripts/start_hypnotoad @@ -0,0 +1,6 @@ +#!/bin/sh + +DIR=$(dirname $0) +export PERL5LIB="$DIR/../lib/" +cd $DIR/.. +hypnotoad -f vroom.pl "$*" diff --git a/templates/default/header.html.ep b/templates/default/header.html.ep index aa65395..3f1e4e4 100644 --- a/templates/default/header.html.ep +++ b/templates/default/header.html.ep @@ -7,7 +7,7 @@ <% foreach my $css (qw(bootstrap.min.css bootstrap-switch.min.css vroom.css)){ %> - /css/<%= $css %>" rel="stylesheet" type="text/css"> + /css/<%= $css %>" rel="stylesheet" type="text/css"> <% } %> diff --git a/templates/default/js_common.html.ep b/templates/default/js_common.html.ep index b531cb0..407edd5 100644 --- a/templates/default/js_common.html.ep +++ b/templates/default/js_common.html.ep @@ -4,5 +4,5 @@ <% foreach my $js (qw(jquery-1.11.1.min.js bootstrap.min.js notify-combined.min.js bootstrap-switch.min.js vroom.js)){ %> - + <% } %> diff --git a/templates/default/js_room.html.ep b/templates/default/js_room.html.ep index 7b1c9a5..099b26e 100644 --- a/templates/default/js_room.html.ep +++ b/templates/default/js_room.html.ep @@ -1,5 +1,5 @@ <% foreach my $js (qw(simplewebrtc.bundle.js jquery.browser.min.js sprintf.js FileSaver.js jquery.tinytimer.min.js etherpad.js)){ %> - + <% } %> diff --git a/public/vroom.pl b/vroom.pl similarity index 99% rename from public/vroom.pl rename to vroom.pl index cfa213c..1e5a7a9 100755 --- a/public/vroom.pl +++ b/vroom.pl @@ -105,7 +105,7 @@ our $musics = { app->log->level('info'); # Read conf file, and set default values our $config = plugin Config => { - file => '../conf/vroom.conf', + file => 'conf/vroom.conf', default => { dbi => 'DBI:mysql:database=vroom;host=localhost', dbUser => 'vroom', @@ -708,7 +708,7 @@ helper ask_for_name => sub { # Randomly choose a music on hold helper choose_moh => sub { my $self = shift; - my @files = (); + my @files = (); return basename($files[rand @files]); }; @@ -1579,7 +1579,7 @@ post '/*action' => [action => [qw/action admin\/action/]] => sub { }; # use the templates defined in the config -push @{app->renderer->paths}, '../templates/'.$config->{template}; +push @{app->renderer->paths}, 'templates/'.$config->{template}; # Set the secret used to sign cookies app->secret($config->{secret}); app->sessions->secure(1); @@ -1591,6 +1591,14 @@ app->hook(before_dispatch => sub { $self->languages($self->session('language')); } }); +# Are we running in hypnotoad ? +app->config( + hypnotoad => { + listen => ['http://127.0.0.1:8090'], + pid_file => '/tmp/vroom.pid', + proxy => 1 + } +); # And start, lets VROOM !! app->start;