【发布时间】:2016-03-09 18:24:07
【问题描述】:
我正在尝试在我的 Debian Wheezy 系统上创建服务。
尝试使用start-stop-daemon运行autossh时,pidfile中包含的pid与autossh进程不匹配。
$ AUTOSSH_PIDFILE=/var/run/padstunnel.pid
$ sudo start-stop-daemon --make-pidfile --background --name mytunnel --start --pidfile /var/run/mytunnel.pid --exec /usr/lib/autossh/autossh -- -M 0 -p 22 user@server -f -T -N -R 31022:localhost:31222
$ ps -elf |grep autossh
1 S root 447 1 0 80 0 - 329 pause 19:07 ? 00:00:00 /usr/lib/autossh/autossh -M 0 -p 22 ...
$ cat /var/run/mytunnel.pid
446
此行为可防止使用 start-stop-daemon 停止 autossh 或使用 pidfile 中的 pid 将其终止。
这种行为有什么原因吗?
如何解决它并使 autossh 的 pid 与 pidfile 匹配?
【问题讨论】:
-
您是否尝试过设置
AUTOSSH_PIDFILE变量并让autossh自己编写pid 文件? -
是的,结果相同
-
那是因为
-f告诉 autossh 进入后台。 (即叉子)。尝试删除它。 -
去掉 `-f` 选项也不好用:然后 autossh 创建了两个进程,pidfile 的 pid 与 root 进程不匹配。在我找到的答案中查看更多信息。