forked from pool/varnish
systemd unit files
OBS-URL: https://build.opensuse.org/package/show/server:http/varnish?expand=0&rev=52
This commit is contained in:
parent
d85a0ca41d
commit
5fe83bda9c
@ -9,6 +9,10 @@ Wed Feb 8 23:26:10 UTC 2012 - jengelh@medozas.de
|
|||||||
* see ChangeLog (packaged) or
|
* see ChangeLog (packaged) or
|
||||||
http://varnish-cache.org/trac/browser/doc/changes.rst
|
http://varnish-cache.org/trac/browser/doc/changes.rst
|
||||||
for details
|
for details
|
||||||
|
- Note that the -s file,/var/cache/varnish,524288 argument (check
|
||||||
|
/etc/sysconfig/varnish) needs at least "1M" instead of 524288
|
||||||
|
or the daemon will not start anymore.
|
||||||
|
- Add systemd unit files
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Thu Dec 8 13:51:14 UTC 2011 - coolo@suse.com
|
Thu Dec 8 13:51:14 UTC 2011 - coolo@suse.com
|
||||||
|
12
varnish.init
12
varnish.init
@ -79,13 +79,10 @@ case "$1" in
|
|||||||
echo -n "Starting varnish "
|
echo -n "Starting varnish "
|
||||||
## Start daemon with startproc(8). If this fails
|
## Start daemon with startproc(8). If this fails
|
||||||
## the return value is set appropriately by startproc.
|
## the return value is set appropriately by startproc.
|
||||||
/sbin/startproc "$VARNISHD_BIN" -P "$VARNISHD_PID" ${VARNISHD_PARAMS:--f /etc/varnish/vcl.conf -T:6082 -s file,/var/cache/varnish,524288 -u varnish}
|
/sbin/startproc "$VARNISHD_BIN" -P "$VARNISHD_PID" ${VARNISHD_PARAMS:--f /etc/varnish/vcl.conf -T:6082 -s file,/var/cache/varnish,1M -u varnish}
|
||||||
|
|
||||||
# Remember status and be verbose
|
# Remember status and be verbose
|
||||||
rc_status -v
|
rc_status -v
|
||||||
echo -n "Starting varnishlog "
|
|
||||||
/sbin/startproc "$VARNISHLOG_BIN" -P "$VARNISHLOG_PID" ${VARNISHLOG_PARAMS:--a -w /var/log/varnish/varnish.log}
|
|
||||||
rc_status -v
|
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
echo -n "Shutting down varnish "
|
echo -n "Shutting down varnish "
|
||||||
@ -96,8 +93,6 @@ case "$1" in
|
|||||||
|
|
||||||
# Remember status and be verbose
|
# Remember status and be verbose
|
||||||
rc_status -v
|
rc_status -v
|
||||||
echo -n "Shutting down varnishlog "
|
|
||||||
/sbin/killproc -p "$VARNISHLOG_PID" "$VARNISHLOG_BIN"
|
|
||||||
;;
|
;;
|
||||||
try-restart|condrestart)
|
try-restart|condrestart)
|
||||||
## Do a restart only if the service was active before.
|
## Do a restart only if the service was active before.
|
||||||
@ -149,8 +144,6 @@ case "$1" in
|
|||||||
/sbin/killproc -p "$VARNISHD_PID" -HUP "$VARNISHD_BIN"
|
/sbin/killproc -p "$VARNISHD_PID" -HUP "$VARNISHD_BIN"
|
||||||
#touch /var/run/varnish.pid
|
#touch /var/run/varnish.pid
|
||||||
rc_status -v
|
rc_status -v
|
||||||
echo -n "Reload service varnishlog "
|
|
||||||
/sbin/killproc -p "$VARNISHLOG_PID" -HUP "$VARNISHLOG_BIN"
|
|
||||||
|
|
||||||
## Otherwise if it does not support reload:
|
## Otherwise if it does not support reload:
|
||||||
#rc_failed 3
|
#rc_failed 3
|
||||||
@ -174,9 +167,6 @@ case "$1" in
|
|||||||
# NOTE: rc_status knows that we called this init script with
|
# NOTE: rc_status knows that we called this init script with
|
||||||
# "status" option and adapts its messages accordingly.
|
# "status" option and adapts its messages accordingly.
|
||||||
rc_status -v
|
rc_status -v
|
||||||
echo -n "Checking for service varnishlog "
|
|
||||||
/sbin/checkproc -p "$VARNISHLOG_PID" "$VARNISHLOG_BIN"
|
|
||||||
rc_status -v
|
|
||||||
;;
|
;;
|
||||||
probe)
|
probe)
|
||||||
## Optional: Probe for the necessity of a reload, print out the
|
## Optional: Probe for the necessity of a reload, print out the
|
||||||
|
11
varnish.service
Normal file
11
varnish.service
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Varnish HTTP accelerator/reverse proxy
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
EnvironmentFile=/etc/sysconfig/varnish
|
||||||
|
PIDFile=/var/run/varnishd.pid
|
||||||
|
ExecStart=/usr/sbin/varnishd $VARNISHD_PARAMS -P /var/run/varnishd.pid -F
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
37
varnish.spec
37
varnish.spec
@ -24,12 +24,15 @@ License: BSD-2-Clause
|
|||||||
Group: Productivity/Networking/Web/Proxy
|
Group: Productivity/Networking/Web/Proxy
|
||||||
URL: http://varnish-cache.org/
|
URL: http://varnish-cache.org/
|
||||||
|
|
||||||
#DL-URL: http://downloads.sourceforge.net/varnish/varnish-%version.tar.bz2
|
#DL-URL: http://downloads.sf.net/varnish/%name-%version.tar.bz2
|
||||||
Source0: %name-%version.tar.xz
|
Source0: %name-%version.tar.xz
|
||||||
Source2: varnish.init
|
Source2: varnish.init
|
||||||
Source3: varnish.sysconfig
|
Source3: varnish.sysconfig
|
||||||
Source4: vcl.conf
|
Source4: vcl.conf
|
||||||
Source5: varnish.logrotate
|
Source5: varnish.logrotate
|
||||||
|
Source6: varnishlog.init
|
||||||
|
Source7: varnish.service
|
||||||
|
Source8: varnishlog.service
|
||||||
|
|
||||||
BuildRoot: %_tmppath/%name-%version-build
|
BuildRoot: %_tmppath/%name-%version-build
|
||||||
BuildRequires: libxslt, ncurses-devel, pcre-devel
|
BuildRequires: libxslt, ncurses-devel, pcre-devel
|
||||||
@ -110,16 +113,18 @@ mv %buildroot/%_bindir/* %buildroot/%_sbindir/
|
|||||||
#
|
#
|
||||||
##missing directories
|
##missing directories
|
||||||
install -d -m 0755 %buildroot{%pkg_logdir,%pkg_home}
|
install -d -m 0755 %buildroot{%pkg_logdir,%pkg_home}
|
||||||
install -D -m 0644 %{S:5} %buildroot%_sysconfdir/logrotate.d/varnish
|
install -Dpm 0644 %{S:5} %buildroot%_sysconfdir/logrotate.d/varnish
|
||||||
#
|
#
|
||||||
##init scripts
|
##init scripts
|
||||||
install -D -m 0644 %{S:3} %buildroot/var/adm/fillup-templates/sysconfig.%name
|
install -Dpm 0644 %{S:3} %buildroot/var/adm/fillup-templates/sysconfig.%name
|
||||||
install -D -m 0755 %{S:2} %buildroot%_sysconfdir/init.d/%name
|
install -Dpm 0755 %{S:2} %buildroot/%_initddir/varnish
|
||||||
ln -s -f %_sysconfdir/init.d/%name %buildroot%_sbindir/rc%name
|
install -Dpm 0755 %{S:6} %buildroot/%_initddir/varnishlog
|
||||||
|
install -Dpm 0644 "%{S:7}" "%buildroot/lib/systemd/system/varnish.service";
|
||||||
|
install -Dpm 0644 "%{S:8}" "%buildroot/lib/systemd/system/varnishlog.service";
|
||||||
#
|
#
|
||||||
##config files
|
##config files
|
||||||
install -D -m 0644 %{S:4} %buildroot%_sysconfdir/%name/vcl.conf
|
install -Dpm 0644 %{S:4} %buildroot%_sysconfdir/%name/vcl.conf
|
||||||
install -D -m 0644 %{S:4} %buildroot%_sysconfdir/%name/vcl.conf.example
|
install -Dpm 0644 %{S:4} %buildroot%_sysconfdir/%name/vcl.conf.example
|
||||||
|
|
||||||
find "%buildroot" -type f -name "*.la" -delete
|
find "%buildroot" -type f -name "*.la" -delete
|
||||||
mkdir -p "%buildroot/%pkg_logdir"
|
mkdir -p "%buildroot/%pkg_logdir"
|
||||||
@ -130,27 +135,28 @@ mkdir -p "%buildroot/%pkg_logdir"
|
|||||||
%_bindir/getent passwd varnish >/dev/null || \
|
%_bindir/getent passwd varnish >/dev/null || \
|
||||||
%_sbindir/useradd -g varnish -s /bin/false -r -c "user for Varnish" \
|
%_sbindir/useradd -g varnish -s /bin/false -r -c "user for Varnish" \
|
||||||
-d %pkg_home varnish || :
|
-d %pkg_home varnish || :
|
||||||
%if 0%{?suse_version}
|
|
||||||
|
|
||||||
%post
|
%post
|
||||||
%fillup_and_insserv %name
|
%fillup_and_insserv varnish
|
||||||
|
%fillup_and_insserv varnishlog
|
||||||
|
|
||||||
%preun
|
%preun
|
||||||
%stop_on_removal %name
|
%stop_on_removal varnish
|
||||||
|
%stop_on_removal varnishlog
|
||||||
|
|
||||||
%postun
|
%postun
|
||||||
%restart_on_update %name
|
%restart_on_update varnish
|
||||||
|
%restart_on_update varnishlog
|
||||||
%insserv_cleanup
|
%insserv_cleanup
|
||||||
%else
|
|
||||||
# how to do the same for RH/mandriva?
|
|
||||||
%endif
|
|
||||||
|
|
||||||
%post -n %library_name -p /sbin/ldconfig
|
%post -n %library_name -p /sbin/ldconfig
|
||||||
%postun -n %library_name -p /sbin/ldconfig
|
%postun -n %library_name -p /sbin/ldconfig
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%defattr(-,root,root)
|
%defattr(-,root,root)
|
||||||
%_initrddir/%name
|
%_initddir/varnish
|
||||||
|
%_initddir/varnishlog
|
||||||
|
/lib/systemd
|
||||||
%config(noreplace) %_sysconfdir/logrotate.d/varnish
|
%config(noreplace) %_sysconfdir/logrotate.d/varnish
|
||||||
%dir %attr(0750,root,varnish) %_sysconfdir/%name/
|
%dir %attr(0750,root,varnish) %_sysconfdir/%name/
|
||||||
%config(noreplace) %attr(0640,root,varnish) %_sysconfdir/%name/vcl.conf
|
%config(noreplace) %attr(0640,root,varnish) %_sysconfdir/%name/vcl.conf
|
||||||
@ -165,7 +171,6 @@ mkdir -p "%buildroot/%pkg_logdir"
|
|||||||
%dir %attr(0750,varnish,varnish) %pkg_logdir
|
%dir %attr(0750,varnish,varnish) %pkg_logdir
|
||||||
|
|
||||||
%if 0%{?suse_version}
|
%if 0%{?suse_version}
|
||||||
%_sbindir/rc%name
|
|
||||||
%_localstatedir/adm/fillup-templates/sysconfig.%name
|
%_localstatedir/adm/fillup-templates/sysconfig.%name
|
||||||
%else
|
%else
|
||||||
%config(noreplace) %_sysconfdir/sysconfig/%name
|
%config(noreplace) %_sysconfdir/sysconfig/%name
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# You might want to keep "/var/cache/varnish" when using the file backend.
|
# You might want to keep "/var/cache/varnish" when using the file backend.
|
||||||
#
|
#
|
||||||
VARNISHD_PARAMS="-f /etc/varnish/vcl.conf -T:6082 -s file,/var/cache/varnish,524288 -u varnish"
|
VARNISHD_PARAMS="-f /etc/varnish/vcl.conf -T:6082 -s file,/var/cache/varnish,1M -u varnish"
|
||||||
|
|
||||||
## Path: Network/WWW/Varnishd
|
## Path: Network/WWW/Varnishd
|
||||||
## Description: Start parameters for varnishlog
|
## Description: Start parameters for varnishlog
|
||||||
|
164
varnishlog.init
Normal file
164
varnishlog.init
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
### BEGIN INIT INFO
|
||||||
|
# Provides: varnishlog
|
||||||
|
# Required-Start: $syslog $remote_fs
|
||||||
|
# Should-Start: $time ypbind sendmail
|
||||||
|
# Required-Stop: $syslog $remote_fs
|
||||||
|
# Should-Stop: $time ypbind sendmail
|
||||||
|
# Default-Start: 3 5
|
||||||
|
# Default-Stop: 0 1 2 6
|
||||||
|
# Short-Description: varnish logger
|
||||||
|
# Description: varnish logger
|
||||||
|
### END INIT INFO
|
||||||
|
|
||||||
|
# Check for missing binaries (stale symlinks should not happen)
|
||||||
|
# Note: Special treatment of stop for LSB conformance
|
||||||
|
VARNISH_BIN=/usr/sbin/varnishd
|
||||||
|
test -x $VARNISH_BIN || { echo "$VARNISH_BIN not installed";
|
||||||
|
if [ "$1" = "stop" ]; then exit 0;
|
||||||
|
else exit 5; fi; }
|
||||||
|
|
||||||
|
# Check for existence of needed config file and read it
|
||||||
|
VARNISH_CONFIG=/etc/sysconfig/varnish
|
||||||
|
test -r $VARNISH_CONFIG || { echo "$VARNISH_CONFIG not existing";
|
||||||
|
if [ "$1" = "stop" ]; then exit 0;
|
||||||
|
else exit 6; fi; }
|
||||||
|
|
||||||
|
VARNISHD_BIN="$VARNISH_BIN"
|
||||||
|
VARNISHD_PID=/var/run/varnishd.pid
|
||||||
|
VARNISHLOG_BIN=/usr/sbin/varnishncsa
|
||||||
|
VARNISHLOG_PID=/var/run/varnishlog.pid
|
||||||
|
|
||||||
|
# Read config
|
||||||
|
. $VARNISH_CONFIG
|
||||||
|
|
||||||
|
# Source LSB init functions
|
||||||
|
# providing start_daemon, killproc, pidofproc,
|
||||||
|
# log_success_msg, log_failure_msg and log_warning_msg.
|
||||||
|
# This is currently not used by UnitedLinux based distributions and
|
||||||
|
# not needed for init scripts for UnitedLinux only. If it is used,
|
||||||
|
# the functions from rc.status should not be sourced or used.
|
||||||
|
#. /lib/lsb/init-functions
|
||||||
|
|
||||||
|
# Shell functions sourced from /etc/rc.status:
|
||||||
|
# rc_check check and set local and overall rc status
|
||||||
|
# rc_status check and set local and overall rc status
|
||||||
|
# rc_status -v be verbose in local rc status and clear it afterwards
|
||||||
|
# rc_status -v -r ditto and clear both the local and overall rc status
|
||||||
|
# rc_status -s display "skipped" and exit with status 3
|
||||||
|
# rc_status -u display "unused" and exit with status 3
|
||||||
|
# rc_failed set local and overall rc status to failed
|
||||||
|
# rc_failed <num> set local and overall rc status to <num>
|
||||||
|
# rc_reset clear both the local and overall rc status
|
||||||
|
# rc_exit exit appropriate to overall rc status
|
||||||
|
# rc_active checks whether a service is activated by symlinks
|
||||||
|
. /etc/rc.status
|
||||||
|
|
||||||
|
# Reset status of this service
|
||||||
|
rc_reset
|
||||||
|
|
||||||
|
# Return values acc. to LSB for all commands but status:
|
||||||
|
# 0 - success
|
||||||
|
# 1 - generic or unspecified error
|
||||||
|
# 2 - invalid or excess argument(s)
|
||||||
|
# 3 - unimplemented feature (e.g. "reload")
|
||||||
|
# 4 - user had insufficient privileges
|
||||||
|
# 5 - program is not installed
|
||||||
|
# 6 - program is not configured
|
||||||
|
# 7 - program is not running
|
||||||
|
# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
|
||||||
|
#
|
||||||
|
# Note that starting an already running service, stopping
|
||||||
|
# or restarting a not-running service as well as the restart
|
||||||
|
# with force-reload (in case signaling is not supported) are
|
||||||
|
# considered a success.
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
echo -n "Starting varnishlog "
|
||||||
|
/sbin/startproc "$VARNISHLOG_BIN" -P "$VARNISHLOG_PID" ${VARNISHLOG_PARAMS:--a -w /var/log/varnish/varnish.log}
|
||||||
|
rc_status -v
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
echo -n "Shutting down varnishlog "
|
||||||
|
/sbin/killproc -p "$VARNISHLOG_PID" "$VARNISHLOG_BIN"
|
||||||
|
rc_status -v
|
||||||
|
;;
|
||||||
|
try-restart|condrestart)
|
||||||
|
## Do a restart only if the service was active before.
|
||||||
|
## Note: try-restart is now part of LSB (as of 1.9).
|
||||||
|
## RH has a similar command named condrestart.
|
||||||
|
if test "$1" = "condrestart"; then
|
||||||
|
echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
|
||||||
|
fi
|
||||||
|
$0 status
|
||||||
|
if test $? = 0; then
|
||||||
|
$0 restart
|
||||||
|
else
|
||||||
|
rc_reset # Not running is not a failure.
|
||||||
|
fi
|
||||||
|
# Remember status and be quiet
|
||||||
|
rc_status
|
||||||
|
;;
|
||||||
|
restart)
|
||||||
|
## Stop the service and regardless of whether it was
|
||||||
|
## running or not, start it again.
|
||||||
|
$0 stop
|
||||||
|
$0 start
|
||||||
|
|
||||||
|
# Remember status and be quiet
|
||||||
|
rc_status
|
||||||
|
;;
|
||||||
|
force-reload)
|
||||||
|
## Signal the daemon to reload its config. Most daemons
|
||||||
|
## do this on signal 1 (SIGHUP).
|
||||||
|
## If it does not support it, restart the service if it
|
||||||
|
## is running.
|
||||||
|
|
||||||
|
"$0" reload
|
||||||
|
rc_status
|
||||||
|
|
||||||
|
## Otherwise:
|
||||||
|
#$0 try-restart
|
||||||
|
#rc_status
|
||||||
|
;;
|
||||||
|
reload)
|
||||||
|
## Like force-reload, but if daemon does not support
|
||||||
|
## signaling, do nothing (!)
|
||||||
|
|
||||||
|
echo -n "Reload service varnishlog "
|
||||||
|
/sbin/killproc -p "$VARNISHLOG_PID" -HUP "$VARNISHLOG_BIN"
|
||||||
|
rc_status -v
|
||||||
|
;;
|
||||||
|
status)
|
||||||
|
## Check status with checkproc(8), if process is running
|
||||||
|
## checkproc will return with exit status 0.
|
||||||
|
|
||||||
|
# Return value is slightly different for the status command:
|
||||||
|
# 0 - service up and running
|
||||||
|
# 1 - service dead, but /var/run/ pid file exists
|
||||||
|
# 2 - service dead, but /var/lock/ lock file exists
|
||||||
|
# 3 - service not running (unused)
|
||||||
|
# 4 - service status unknown :-(
|
||||||
|
# 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
|
||||||
|
|
||||||
|
echo -n "Checking for service varnishlog "
|
||||||
|
/sbin/checkproc -p "$VARNISHLOG_PID" "$VARNISHLOG_BIN"
|
||||||
|
rc_status -v
|
||||||
|
;;
|
||||||
|
probe)
|
||||||
|
## Optional: Probe for the necessity of a reload, print out the
|
||||||
|
## argument to this init script which is required for a reload.
|
||||||
|
## Note: probe is not (yet) part of LSB (as of 1.9)
|
||||||
|
|
||||||
|
test /etc/sysconfig/varnish -nt "$VARNISHD_PID" && \
|
||||||
|
test -f /etc/varnish/default.vcl.net -nt "$VARNISHD_PID" && \
|
||||||
|
echo reload
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
rc_exit
|
10
varnishlog.service
Normal file
10
varnishlog.service
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Varnish log generator
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
EnvironmentFile=/etc/sysconfig/varnish
|
||||||
|
PIDFile=/var/run/varnishlog.pid
|
||||||
|
ExecStart=/usr/sbin/varnishncsa $VARNISHLOG_PARAMS -P /var/run/varnishlog.pid -F
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Loading…
Reference in New Issue
Block a user