sbin / start-stop-daemon无法启动python – ubuntu docker容器
我有一个简单的Python脚本,我想在Docker容器中的后台启动一个守护进程服务
/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)
但是,当在shell中执行下面的命令时,它就起作用了
python /opt/app/uc/monitor/bin/my-application.py
我确定python已经安装,所有的链接都已经安装好了。
谢谢您的帮助
这个错误信息意味着start-stop-daemon
正在寻找一个打开的文件(在打开文件之前stat是一个检查)并且把你的'python ... '
参数看作是一个文件。
看到这个证实这一点的例子 。 您可能需要阅读Ubuntu版本的start-stop-daemon手册页 ,以检查您的安装程序的有效命令。
最简单的解决scheme可能是创build一个shell脚本(比如/opt/app/uc/monitor/bin/run-my-application.sh
),并将其放入:
#!/bin/bash python /opt/app/uc/monitor/bin/my-application.py
一定要在这个文件上执行chmod +x
。 如果没有findpython,请使用which python
findwhich python
的path,并在脚本中使用它。
现在尝试:
/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'