]> git.pld-linux.org Git - packages/varnish.git/blame - varnishncsa.init
do not overwrite upstream default.vcl with an outdated copy
[packages/varnish.git] / varnishncsa.init
CommitLineData
10a98a3c
ER
1#!/bin/sh
2#
3# varnishncsa Control the varnish nsca logging daemon
4#
5# chkconfig: 345 90 10
6#
7# description: Varnish HTTP accelerator logging daemon
8#
9# processname: varnishncsa
10# pidfile: /var/run/varnish/varnishncsa.pid
11#
12# $Id$
13
14# Source function library
15. /etc/rc.d/init.d/functions
16
17# Get service config - may override defaults
18[ -f /etc/sysconfig/varnishncsa ] && . /etc/sysconfig/varnishncsa
19
20pidfile="/var/run/varnishncsa.pid"
21logfile="/var/log/varnish/access.log"
22
23start() {
24 # Check if the service is already running?
25 if [ -f /var/lock/subsys/varnishncsa ]; then
26 msg_already_running "Varnish NCSA logging daemon"
27 return
28 fi
29
32860f50
ER
30 # NCSA log format, to be used by HTTP log analyzers
31 if ! is_yes "$VARNISHNCSA_ENABLED"; then
32 return
33 fi
34
496836f4 35 local opts
32860f50 36 if is_yes "$LOG_BACKEND"; then
496836f4
ER
37 opts="$opts -b"
38 fi
39
32860f50 40 if is_yes "$LOG_CLIENT"; then
496836f4
ER
41 opts="$opts -c"
42 fi
43
52a65af7
ER
44 # -b and -c specified together does not work,
45 # however specifing neither of them assumes both are set
46 if is_yes "$LOG_BACKEND" && is_yes "$LOG_CLIENT"; then
47 opts=""
48 fi
49
10a98a3c 50 msg_starting "Varnish NCSA logging daemon"
4d318636 51 daemon --pidfile $pidfile /usr/bin/varnishncsa -a -w $logfile -D -P $pidfile $opts
10a98a3c
ER
52 RETVAL=$?
53 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/varnishncsa
54}
55
56stop() {
57 if [ ! -f /var/lock/subsys/varnishncsa ]; then
58 msg_not_running "Varnish NCSA logging daemon"
59 return
60 fi
61
62 # Stop daemons.
63 msg_stopping "Varnish NCSA logging daemon"
64 killproc --pidfile $pidfile varnishncsa
65 rm -f /var/lock/subsys/varnishncsa
66}
67
68condrestart() {
69 if [ ! -f /var/lock/subsys/varnishncsa ]; then
70 msg_not_running "Varnish NCSA logging daemon"
71 RETVAL=$1
72 return
73 fi
74
75 stop
76 start
77}
78
980065e2
ER
79reload() {
80 if [ ! -f /var/lock/subsys/varnishncsa ]; then
81 msg_not_running "Varnish NCSA logging daemon"
82 RETVAL=7
83 return
84 fi
85
86 msg_reloading "Varnish NCSA logging daemon"
87 killproc --pidfile $pidfile varnishncsa -HUP
88}
89
5b4beeaf
ER
90flush-logs() {
91 if [ ! -f /var/lock/subsys/varnishncsa ]; then
92 msg_not_running "Varnish NCSA logging daemon"
93 return
94 fi
95
96 show "Rotating %s logs" "Varnish NCSA logging daemon"
97 killproc --pidfile $pidfile varnishncsa -HUP
98 RETVAL=$?
99}
100
10a98a3c
ER
101RETVAL=0
102# See how we were called.
103case "$1" in
104 start)
980065e2 105 start
10a98a3c
ER
106 ;;
107 stop)
980065e2 108 stop
10a98a3c
ER
109 ;;
110 restart)
111 stop
112 start
113 ;;
114 try-restart)
115 condrestart 0
116 ;;
980065e2
ER
117 reload|force-reload)
118 reload
10a98a3c 119 ;;
5b4beeaf
ER
120 flush-logs)
121 flush-logs
122 ;;
10a98a3c
ER
123 status)
124 status varnishncsa
125 RETVAL=$?
126 ;;
127 *)
5b4beeaf 128 msg_usage "$0 {start|stop|restart|try-restart|force-reload|flush-logs|status}"
10a98a3c
ER
129 exit 3
130esac
131
132exit $RETVAL
This page took 0.042829 seconds and 4 git commands to generate.