subversion package in debian jessie does not include a systemd service file. what is the simplest solution for automatic start. i try
[Unit]
Description=Subversion protocol daemon
After=syslog.target network.target
[Service]
Type=forking
#EnvironmentFile=/etc/conf.d/svnserve
#ExecStart=/usr/bin/svnserve --daemon $SVNSERVE_ARGS
ExecStart=/usr/bin/svnserve -d -r /svnFolder/repositories
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target
Alias=svnserve.service
it is an adaptation of https://bbs.archlinux.org/viewtopic.php?id=190127 but i have put the arguments directly for svnserve directly here.
what can be improved?
Here is a proposal to setup svnserve
service "the-Debian-way" running with a dedicated svn
service account with proper logging. According to FHS, repositories should be stored in /srv/
:
mkdir -p /srv/svn/repos; chown svn /srv/svn/repos
First, the service configuration for systemd /etc/systemd/system/svnserve.service
:
[Unit]
Description=Subversion protocol daemon
After=syslog.target network.target
[Service]
Type=forking
RuntimeDirectory=svnserve
PIDFile=/run/svnserve/svnserve.pid
EnvironmentFile=/etc/default/svnserve
ExecStart=/usr/bin/svnserve $DAEMON_ARGS
User=svn
Group=svn
KillMode=control-group
Restart=on-failure
[Install]
WantedBy=multi-user.target
Second, the service startup options at /etc/default/svnserve
:
# svnserve options
DAEMON_ARGS="--daemon --pid-file /run/svnserve/svnserve.pid --root /srv/svn/repos --log-file /var/log/svnserve/svnserve.log"
To work properly, the folder for log files must be created with proper ownership and run location for pid file too:
mkdir /var/log/svnserve; chown svn /var/log/svnserve
mkdir -p /run/svnserve; chown svn /run/svnserve
To end with log rotation configuration /etc/logrotate.d/svnserve
:
/var/log/svnserve/*.log {
daily
missingok
rotate 14
compress
notifempty
create 640 svn adm
sharedscripts
postrotate
if /bin/systemctl status svnserve > /dev/null ; then \
/bin/systemctl restart svnserve > /dev/null; \
fi;
endscript
}
Hope this helps.