aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGareth Rees <gareth@mysociety.org>2014-07-25 16:55:22 +0100
committerGareth Rees <gareth@mysociety.org>2014-08-04 15:30:29 +0100
commit50eee6378d620b5d9d4f994581258e89788969ca (patch)
tree20573ae66dc93f1926660afcc623a47ac74c7b10
parent453a4acd8d062ce1c500ce30af5b4b70ab5ded64 (diff)
Ensure the log and pid directories exist
If the directories do not exist the daemon cannot start.
-rwxr-xr-xconfig/purge-varnish-debian.ugly10
1 files changed, 8 insertions, 2 deletions
diff --git a/config/purge-varnish-debian.ugly b/config/purge-varnish-debian.ugly
index 78be365dc..dc3f74ff6 100755
--- a/config/purge-varnish-debian.ugly
+++ b/config/purge-varnish-debian.ugly
@@ -15,8 +15,10 @@
NAME=!!(*= $daemon_name *)!!
DAEMON=!!(*= $vhost_dir *)!!/!!(*= $vcspath *)!!/script/runner
DAEMON_ARGS="--daemon PurgeRequest.purge_all_loop"
-PIDFILE=!!(*= $vhost_dir *)!!/!!(*= $vcspath *)!!/tmp/pids/!!(*= $daemon_name *)!!.pid
-LOGFILE=!!(*= $vhost_dir *)!!/!!(*= $vcspath *)!!/log/!!(*= $daemon_name *)!!.log
+PIDDIR=!!(*= $vhost_dir *)!!/!!(*= $vcspath *)!!/tmp/pids
+PIDFILE=$PIDDIR/!!(*= $daemon_name *)!!.pid
+LOGDIR=!!(*= $vhost_dir *)!!/!!(*= $vcspath *)!!/log
+LOGFILE=$LOGDIR/!!(*= $daemon_name *)!!.log
DUSER=!!(*= $user *)!!
# Set RAILS_ENV - not needed if using config/rails_env.rb
# RAILS_ENV=your_rails_env
@@ -29,10 +31,14 @@ trap "" 1
export PIDFILE LOGFILE
quietly_start_daemon() {
+ mkdir -p {$LOGDIR,$PIDDIR}
+ chown $DUSER:$DUSER {$LOGDIR,$PIDDIR}
/sbin/start-stop-daemon --quiet --start --pidfile "$PIDFILE" --chuid "$DUSER" --startas "$DAEMON" -- $DAEMON_ARGS
}
start_daemon() {
+ mkdir -p {$LOGDIR,$PIDDIR}
+ chown $DUSER:$DUSER {$LOGDIR,$PIDDIR}
/sbin/start-stop-daemon --start --pidfile "$PIDFILE" --chuid "$DUSER" --startas "$DAEMON" -- $DAEMON_ARGS
}