Add support for systemd timers for phpsessionclean

* Add systemd timer and service for phpsessionclean
* Add check to run phphsessionclean from cron only
  when not using systemd
This commit is contained in:
Daniel Schaal 2016-12-27 09:31:46 +01:00 committed by Ondřej Surý
parent b5ed906aa2
commit 87f0c9270d
6 changed files with 32 additions and 3 deletions

2
debian/control vendored
View file

@ -5,7 +5,7 @@ Maintainer: Debian PHP Maintainers <pkg-php-maint@lists.alioth.debian.org>
Uploaders: Ondřej Surý <ondrej@debian.org>,
Lior Kaplan <kaplan@debian.org>
Standards-Version: 3.9.8
Build-Depends: debhelper (>= 9)
Build-Depends: debhelper (>= 9), dh-systemd
Vcs-Browser: https://anonscm.debian.org/cgit/pkg-php/php-defaults.git
Vcs-Git: git://anonscm.debian.org/pkg-php/php-defaults.git

View file

@ -3,3 +3,5 @@ php-maintscript-helper /usr/lib/php/
phpenmod /usr/sbin/
phpquery /usr/sbin/
sessionclean /usr/lib/php/
debian/phpsessionclean.timer /lib/systemd/system/
debian/phpsessionclean.service /lib/systemd/system/

View file

@ -11,4 +11,4 @@
# sessions yourself.
# Look for and purge old sessions every 30 minutes
09,39 * * * * root [ -x /usr/lib/php/sessionclean ] && /usr/lib/php/sessionclean
09,39 * * * * root [ -x /usr/lib/php/sessionclean ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean; fi

11
debian/phpsessionclean.service vendored Normal file
View file

@ -0,0 +1,11 @@
[Unit]
Description=Clean php session files
[Service]
Type=oneshot
ExecStart=/usr/lib/php/sessionclean
ProtectHome=true
ProtectSystem=true
PrivateTmp=true
PrivateDevices=true
PrivateNetwork=true

9
debian/phpsessionclean.timer vendored Normal file
View file

@ -0,0 +1,9 @@
[Unit]
Description=Clean PHP session files every 30 mins
[Timer]
OnCalendar=*-*-* *:09,39:00
Persistent=true
[Install]
WantedBy=timers.target

9
debian/rules vendored
View file

@ -32,7 +32,7 @@ ifeq (Ubuntu,$(DEB_VENDOR))
endif
%:
dh $@
dh $@ --with systemd
override_dh_auto_configure:
:
@ -86,4 +86,11 @@ override_dh_gencontrol:
dh_gencontrol -pphp-all-dev -- -v$(PHP_COMMON_DEB_VERSION)
dh_gencontrol --remaining-packages -- -v$(PHP_DEB_VERSION)
override_dh_systemd_enable:
dh_systemd_enable --package=php-common phpsessionclean.timer
override_dh_systemd_start:
dh_systemd_start --package=php-common phpsessionclean.timer
dh_systemd_start --package=php-common --no-start phpsessionclean.service
.PHONY: debian/control