diff options
-rw-r--r-- | Bugzilla/DaemonControl.pm | 2 | ||||
-rw-r--r-- | Bugzilla/Quantum.pm | 3 | ||||
-rw-r--r-- | Bugzilla/Quantum/Plugin/Glue.pm | 9 | ||||
-rwxr-xr-x | bugzilla.pl | 2 | ||||
-rw-r--r-- | vagrant_support/apache.yml | 4 | ||||
-rwxr-xr-x | vagrant_support/hypnotoad | 121 | ||||
-rw-r--r-- | vagrant_support/hypnotoad.yml | 26 | ||||
-rw-r--r-- | vagrant_support/playbook.yml | 3 | ||||
-rw-r--r-- | vagrant_support/update.yml | 5 |
9 files changed, 167 insertions, 8 deletions
diff --git a/Bugzilla/DaemonControl.pm b/Bugzilla/DaemonControl.pm index 19bc440f7..9cea1a898 100644 --- a/Bugzilla/DaemonControl.pm +++ b/Bugzilla/DaemonControl.pm @@ -105,7 +105,7 @@ sub run_httpd { # or else apache will kill its parent. setsid(); $ENV{BUGZILLA_HTTPD_ARGS} = encode_json(\@args); - my @command = ( $^X, '/app/bugzilla.pl', 'daemon', "--listen=http://*:$ENV{PORT}" ); + my @command = ( $^X, '/app/local/bin/hypnotoad', '/app/bugzilla.pl', '-f' ); exec @command or die "failed to exec $command[0] $!"; }, diff --git a/Bugzilla/Quantum.pm b/Bugzilla/Quantum.pm index 7209a204b..d9bb7a75a 100644 --- a/Bugzilla/Quantum.pm +++ b/Bugzilla/Quantum.pm @@ -33,9 +33,6 @@ sub startup { my ($self) = @_; $self->plugin('Bugzilla::Quantum::Plugin::Glue'); - my $port = $ENV{PORT} // 3000; - untaint($port); - $self->config(hypnotoad => {listen => ["http://*:$port"]}); my $r = $self->routes; Bugzilla::Quantum::CGI->load_all($r); diff --git a/Bugzilla/Quantum/Plugin/Glue.pm b/Bugzilla/Quantum/Plugin/Glue.pm index b46ffb1e1..19896817c 100644 --- a/Bugzilla/Quantum/Plugin/Glue.pm +++ b/Bugzilla/Quantum/Plugin/Glue.pm @@ -29,6 +29,13 @@ sub register { } } + # hypnotoad is weird and doesn't look for MOJO_LISTEN itself. + $app->config( + hypnotoad => { + listen => [ $ENV{MOJO_LISTEN} ], + }, + ); + $app->hook( around_dispatch => sub { my ($next, $c) = @_; @@ -86,4 +93,4 @@ sub register { -1;
\ No newline at end of file +1; diff --git a/bugzilla.pl b/bugzilla.pl index 505b44982..41a4d8e6a 100755 --- a/bugzilla.pl +++ b/bugzilla.pl @@ -14,5 +14,7 @@ BEGIN { } use Mojolicious::Commands; +$ENV{MOJO_LISTEN} ||= $ENV{PORT} ? "http://*:$ENV{PORT}" : "http://*:3001"; + # Start command line interface for application Mojolicious::Commands->start_app('Bugzilla::Quantum'); diff --git a/vagrant_support/apache.yml b/vagrant_support/apache.yml index 4ddd1e7b2..2d65965ab 100644 --- a/vagrant_support/apache.yml +++ b/vagrant_support/apache.yml @@ -7,7 +7,7 @@ when: LAZY == 0 - name: disable httpd - service: name=httpd enabled=yes + service: name=httpd enabled=no when: LAZY == 0 - name: ensure bugzilla.log has right permissions @@ -17,4 +17,4 @@ file: path=/vagrant/logs/bugzilla-json.log state=touch owner=vagrant group=apache mode=0660 - name: stop httpd - service: name=httpd state=stopped
\ No newline at end of file + service: name=httpd state=stopped diff --git a/vagrant_support/hypnotoad b/vagrant_support/hypnotoad new file mode 100755 index 000000000..bd5fb3a2e --- /dev/null +++ b/vagrant_support/hypnotoad @@ -0,0 +1,121 @@ +#!/bin/bash +# +# bugzilla-push This starts, stops, and restarts the Bugzilla push +# daemon, which manages syncronising bugzilla.mozilla.org and +# third party bugzilla installs. +# +# chkconfig: 345 85 15 +# description: Bugzilla push daemon +# +### BEGIN INIT INFO +# Provides: bugzilla-push +# Required-Start: $local_fs $syslog MTA mysqld +# Required-Stop: $local_fs $syslog MTA mysqld +# Default-Start: 3 5 +# Default-Stop: 0 1 2 6 +# Short-Description: Start and stop the Bugzilla push daemon. +# Description: The Bugzilla push daemon (bugzilla-pushd.pl) +# +# +# +### END INIT INFO + +NAME=`basename $0` + +################# +# Configuration # +################# + +# This should be the path to your Bugzilla +BUGZILLA=/vagrant +# Who owns the Bugzilla directory and files? +USER=vagrant + +PERL5LIB="$BUGZILLA:$BUGZILLA/lib:$BUGZILLA/local/lib/perl5" +export PERL5LIB + +if [[ x$PORT == x ]]; then + PORT=80 + export PORT +fi + +# If you want to pass any options to the daemon (like -d for debugging) +# specify it here. +OPTIONS="" + +# You can also override the configuration by creating a +# /etc/sysconfig/bugzilla-queue file so that you don't +# have to edit this script. +if [ -r /etc/sysconfig/$NAME ]; then + . /etc/sysconfig/$NAME +fi + +########## +# Script # +########## + +RETVAL=0 +BIN="$BUGZILLA/local/bin/hypnotoad" +PIDFILE="$BUGZILLA/hypnotoad.pid" + +# Source function library. +. /etc/rc.d/init.d/functions + +usage () +{ + echo "Usage: service $NAME {start|stop|status|restart|condrestart}" + RETVAL=1 +} + + +start () +{ + if [[ -f $PIDFILE ]]; then + checkpid "$(cat $PIDFILE)" && return 0 + fi + echo -n "Starting $NAME: " + daemon --pidfile=$PIDFILE --user=$USER "cd $BUGZILLA && $BIN bugzilla.pl >/dev/null" + ret=$? + [ $ret -eq "0" ] && touch /var/lock/subsys/$NAME + echo + return $ret +} + +stop () +{ + cd $BUGZILLA && $BIN bugzilla.pl --stop + rm -f /var/lock/subsys/$NAME +} + +restart () +{ + stop + start +} + +condrestart () +{ + [ -e /var/lock/subsys/$NAME ] && restart || return 0 +} + +status () +{ + if [[ -f $PIDFILE ]] && checkpid "$(cat $PIDFILE)"; then + echo hypnotoad is amazing + return 0 + else + echo hypnotoad is not running + return 1 + fi +} + +case "$1" in + start) start; RETVAL=$? ;; + stop) stop; RETVAL=$? ;; + status) status; RETVAL=$?;; + restart) restart; RETVAL=$? ;; + condrestart) condrestart; RETVAL=$? ;; + *) usage ; RETVAL=2 ;; +esac + +exit $RETVAL diff --git a/vagrant_support/hypnotoad.yml b/vagrant_support/hypnotoad.yml new file mode 100644 index 000000000..9379b0c3c --- /dev/null +++ b/vagrant_support/hypnotoad.yml @@ -0,0 +1,26 @@ +- name: grant perl ability to listen to privledged ports + command: setcap 'cap_net_bind_service=+ep' /usr/bin/perl + +- name: hypnotoad daemon sysconfig + copy: + dest: /etc/sysconfig/hypnotoad + mode: 0644 + content: | + BUGZILLA=/vagrant + USER=vagrant + +- name: hypnotoad daemon init file + template: + dest: /etc/init.d/hypnotoad + src: hypnotoad + owner: root + group: root + mode: 0755 + +- name: enable hypnotoad + service: name=hypnotoad enabled=yes + when: LAZY == 0 + +- name: restart hypnotoad + service: name=hypnotoad state=restarted + diff --git a/vagrant_support/playbook.yml b/vagrant_support/playbook.yml index c067eab05..82fbba4a2 100644 --- a/vagrant_support/playbook.yml +++ b/vagrant_support/playbook.yml @@ -222,5 +222,8 @@ - include_tasks: apache.yml vars: LAZY: 0 + - include_tasks: hypnotoad.yml + vars: + LAZY: 0 - import_tasks: devtools.yml diff --git a/vagrant_support/update.yml b/vagrant_support/update.yml index c53a0554e..533da5b5e 100644 --- a/vagrant_support/update.yml +++ b/vagrant_support/update.yml @@ -20,4 +20,7 @@ LAZY: 1 - include_tasks: apache.yml vars: - LAZY: 1
\ No newline at end of file + LAZY: 1 + - include_tasks: hypnotoad.yml + vars: + LAZY: 1 |