Python 守护进程子进程在启动时不工作
我正在尝试编写一个将在启动时启动的 python 守护进程。该脚本的目标是从 gearman 负载平衡服务器接收作业并完成该作业。我正在使用 pypi 中的 python-daemon 模块 (http://pypi.python.org/ pypi/python-daemon/)。它所完成的工作的本质是将 orf(奥林巴斯原始图像格式)的图像转换为 jpeg。为了实现这一点,需要使用外部程序,在本例中为 ufraw。当我在启动时启动守护进程时,问题就出现了,如果我从 shell 启动,它会完美运行并完成工作。当它在引导时启动时,它无法启动子进程命令。
commandString = '/usr/bin/ufraw-batch --interpolation=four-color --wb=camera --compression=100 --output="' + outfile + '" --out-type=jpg --overwrite "' + infile + '"'
args = shlex.split(commandString)
process = subprocess.Popen(args).wait()
我不确定我做错了什么。感谢您的任何帮助。
I am attempting to write a python daemon that will launch at boot. The goal of the script is to receive a job from our gearman load balancing server and complete the job. I am using the python-daemon module from pypi (http://pypi.python.org/pypi/python-daemon/). The nature of the job that it is completing is converting images in the orf (olympus raw image format) to jpeg. In order to accomplish this an outside program is used, ufraw in this case. The problem comes in when I start the daemon at boot, if I launch from the shell it runs perfectly and completes the work. When it starts at boot it is unable to launch the subprocess command.
commandString = '/usr/bin/ufraw-batch --interpolation=four-color --wb=camera --compression=100 --output="' + outfile + '" --out-type=jpg --overwrite "' + infile + '"'
args = shlex.split(commandString)
process = subprocess.Popen(args).wait()
I am not sure what I am doing wrong. Thanks for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该问题与 python 无关,而是与 ubuntu init.d 守护进程有关。我假设 python 脚本是作为用户使用的,但事实证明并非如此。为了解决这个问题,我在 init.d 脚本中添加了 sudo 命令,子进程现在成功启动。
The issue is not related to python but rather related to the ubuntu init.d daemon. I assumed that the python script was being as a user turns out that it is not. To remedy the problem I added a sudo command to the init.d script and the subprocess starts successfully now.