aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorroot <root>2008-09-08 10:45:28 +0000
committerroot <root>2008-09-08 10:45:28 +0000
commit795a8b36a1331e312a006878ab6d51ba5e88352b (patch)
tree43609a4d3e8e2a4074973fe5c42c09b1a47aaf3b
parent8bce886207edfb1cea8d8b4977606cdbd95e9bb4 (diff)
Mongrel run as a daemon
-rw-r--r--config/foimongreld.ugly (renamed from config/foimongreld.sh)16
-rwxr-xr-xscript/restart-mongrel29
2 files changed, 13 insertions, 32 deletions
diff --git a/config/foimongreld.sh b/config/foimongreld.ugly
index efb079454..9eaecb714 100644
--- a/config/foimongreld.sh
+++ b/config/foimongreld.ugly
@@ -3,14 +3,24 @@
# !!(*= $daemon_name *)!! Start the WhatDoTheyKnow web server daemon (mongrel)
NAME=!!(*= $daemon_name *)!!
+RUNDIR=/data/vhost/!!(*= $vhost *)!!/mysociety/foi
PIDFILE=/data/vhost/!!(*= $vhost *)!!/mysociety/foi/log/mongrel.pid
DUSER=!!(*= $user *)!!
function stop_mongrel {
if [ -e $PIDFILE ]
then
- su -c "/usr/bin/ruby -I/usr/lib/ruby/ /usr/bin/mongrel_rails stop --force --wait 5"
- # if --force kicks in, needs to remove the pidfile
+ su $DUSER -c "cd $RUNDIR; /usr/bin/ruby -I/usr/lib/ruby/ /usr/bin/mongrel_rails stop"
+ sleep 5s
+ if [ -e $PIDFILE ]
+ then
+ if ( ps h -p `cat $PIDFILE` )
+ then
+ echo "kill -9 ing `cat $PIDFILE` because it failed to stop"
+ kill -9 `cat $PIDFILE`
+ sleep 2s
+ fi
+ fi
if [ -e $PIDFILE ]
then
rm $PIDFILE
@@ -27,7 +37,7 @@ function start_mongrel {
echo " pidfile already exists, stop first "
return 1
else
- su -c "/usr/bin/ruby -I/usr/lib/ruby/ /usr/bin/mongrel_rails start -d"
+ su $DUSER -c "cd $RUNDIR; /usr/bin/ruby -I/usr/lib/ruby/ /usr/bin/mongrel_rails start -d"
fi
}
diff --git a/script/restart-mongrel b/script/restart-mongrel
deleted file mode 100755
index 35c0468f4..000000000
--- a/script/restart-mongrel
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/bash
-
-# Stops and restarts the Mongrel web server.
-
-cd `dirname $0`
-cd ..
-# XXX Include path for dodgy version of daemonize package
-if [ -e log/mongrel.pid ]
-then
- ruby -I/usr/lib/ruby/ /usr/bin/mongrel_rails stop
- sleep 5s
- if [ -e log/mongrel.pid ]
- then
- if ( ps h -p `cat log/mongrel.pid` )
- then
- echo "kill -9 ing `cat log/mongrel.pid` because it failed to stop"
- kill -9 `cat log/mongrel.pid`
- sleep 2s
- fi
- fi
- if [ -e log/mongrel.pid ]
- then
- rm log/mongrel.pid
- fi
- ruby -I/usr/lib/ruby/ /usr/bin/mongrel_rails start -d
-else
- ruby -I/usr/lib/ruby/ /usr/bin/mongrel_rails start -d
-fi
-