2016-12-14 100 views
0

我有我想在背景中泊坞窗容器启动一个后台程序服务的一个简单的Python脚本sbin目录/启动停止守护进程无法启动蟒蛇 - Ubuntu的搬运工集装箱

/sbin/start-stop-daemon --start --user root --make-pidfile --pidfile /var/lock/subsys/my-application.pid --exec 'python /opt/app/uc/monitor/bin/my-application.py' 

当我执行这个命令在shell我得到

/sbin/start-stop-daemon: unable to stat //python /opt/app/uc/monitor/bin/my-application.py (No such file or directory) 

然而,当在外壳只执行下面的命令,它的工作原理

python /opt/app/uc/monitor/bin/my-application.py 

我确定安装了python,并且所有链接都已经安装。

感谢您的帮助

+0

码头工人是不是虚拟机。没有暴发户,因此没有启动守护进程。如果必须,请检查runit或supervisor。或者你可以坚持一个过程/一个容器的“最佳实践”。 – user2105103

+0

我想到并创建了一个启动脚本... – Manjesh

回答

1

该错误消息意味着start-stop-daemon正在寻找一个文件打开(STAT是检查它打开文件前)和治疗您的'python ... '说法,如果它是一个文件。

请参阅this example这证实了这一点。您可能需要阅读您的Ubuntu版本man page for start-stop-daemon,以检查您的设置有效的命令。

简单的解决方案可能是创建一个shell脚本(比如/opt/app/uc/monitor/bin/run-my-application.sh),并把这个进去:

#!/bin/bash 
python /opt/app/uc/monitor/bin/my-application.py 

一定要对这个文件做chmod +x。如果未找到python,请使用which python查找到python的路径并在脚本中使用该路径。

现在试试:

/sbin/start-stop-daemon --start --user root --make-pidfile --pidfile /var/lock/subsys/my-application.pid --exec '/opt/app/uc/monitor/bin/run-my-application.sh'