问题描述
debian jessie 中的 subversion 包不包含 systemd 服务文件.什么是最简单的自动启动解决方案.我试试
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
它是对https://bbs.archlinux.org/viewtopic.php的改编?id=190127 但我已经将参数直接放在了 svnserve 此处.
it is an adaptation of https://bbs.archlinux.org/viewtopic.php?id=190127 but i have put the arguments directly for svnserve directly here.
有什么可以改进的?
推荐答案
这里有一个设置 svnserve
服务the-Debian-way"的建议使用具有适当日志记录的专用 svn
服务帐户运行.根据 FHS,存储库应存储在 /srv/
中:
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
一、systemd的服务配置/etc/systemd/system/svnserve.service
:
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
二、/etc/default/svnserve
处的服务启动选项:
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"
要正常工作,日志文件的文件夹也必须以正确的所有权和运行位置为 pid 文件创建:
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
以日志轮换配置结束 /etc/logrotate.d/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
}
希望这会有所帮助.
这篇关于如何使用 systemctl systemd 启动 svnserve的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!