我无法使用systemd服务文件运行tmux & rtorrent。我的rtorrent.service:
[Unit]
Description=rTorrent
Documentation=https://github.com/rakshasa/rtorrent
After=network.target local-fs.target
[Service]
Type=forking
KillMode=none
User=rtorrent
ExecStart=/usr/bin/tmux -S /tmp/rtorrent.sock new-session -d -s rtorrent \'rtorrent -n -O import=/etc/rtorrent.rc\'
ExecStop=/usr/bin/tmux -S /tmp/rtorrent.sock send-keys -t rtorrent C-q
WorkingDirectory=/home/rtorrent
[Install]
WantedBy=default.target(将Type=oneshot与RemainAfterExit=yes结合使用是行不通的,而且我也不相信这是一个解决方案。我认为以这种方式运行tmux应该用Type=forking来完成。如果我错了,请纠正我!)
来自systemctl status rtorrent的输出:
● rtorrent.service - rTorrent
Loaded: loaded (/etc/systemd/system/rtorrent.service; disabled)
Active: failed (Result: exit-code) since Mon 2015-04-27 10:48:37 AEST; 22s ago
Docs: https://github.com/rakshasa/rtorrent
Process: 4433 ExecStart=/usr/bin/tmux -S /tmp/rtorrent.sock new-session -d -s rtorrent 'rtorrent -n -O import=/etc/rtorrent/rtorrent.rc' (code=exited, status=1/FAILURE)
Apr 27 10:48:37 vagrant tmux[4433]: usage: new-session [-AdDP] [-c start-directory] [-F format] [-n window-name] [-s session-name] [-t target-session] [-x width] [-y height] [command]
Apr 27 10:48:37 vagrant systemd[1]: rtorrent.service: control process exited, code=exited status=1
Apr 27 10:48:37 vagrant systemd[1]: Failed to start rTorrent.
Apr 27 10:48:37 vagrant systemd[1]: Unit rtorrent.service entered failed state.通过切换到rtorrent用户,使用su,我可以手动尝试ExecStart命令--这很好。我无法进一步调试它。
有什么想法?谢谢!
发布于 2015-04-27 02:16:24
systemd自己解释Exec和其他键的值。因此,您不应该将它传递给sh -c或诸如此类的东西。特别是,如果你想把一组单词当作一个参数来处理,就像往常一样引用它,不要逃避引号。请考虑系统文档中的这个示例:
示例: ExecStart=/bin/echo one;/bin/echo“两次”--这将执行
/bin/echo两次,每次使用一个参数:one和two two。因为指定了两个命令,所以必须使用Type=oneshot。
因此,ExecStart行应该是:
ExecStart=/usr/bin/tmux -S /tmp/rtorrent.sock new-session -d -s rtorrent 'rtorrent -n -O import=/etc/rtorrent.rc'https://unix.stackexchange.com/questions/198771
复制相似问题