Python守护程序打包最佳实践 [英] Python Daemon Packaging Best Practices

查看:68
本文介绍了Python守护程序打包最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用python编写的工具,通常应作为守护程序运行.打包此分发工具的最佳实践是什么,特别是应该如何处理设置文件和守护程序可执行文件/脚本?

I have a tool which I have written in python and generally should be run as a daemon. What are the best practices for packaging this tool for distribution, particularly how should settings files and the daemon executable/script be handled?

相应地,有任何通用工具可用于设置守护程序以在给定平台上运行,以适合给定平台(例如,Linux上的 init 脚本,Windows上的服务, launchd 在OS X上)?

Relatedly are there any common tools for setting up the daemon for running on boot as appropriate for the given platform (i.e. init scripts on linux, services on windows, launchd on os x)?

推荐答案

要回答您的问题的一部分,据我所知,没有工具可以甚至在Linux系统(甚至是Windows或Mac OS X)上都可移植地进行守护程序设置.

To answer one part of your question, there are no tools I know of that will do daemon setup portably even across Linux systems let alone Windows or Mac OS X.

现在大多数Linux发行版似乎都在init脚本中使用了start-stop-daemon,但是文件系统布局和包装上的差别仍然很小.如果您的项目全部是Python,则使用autotools/configure或distutils/easy_install可以大大简化构建针对不同Linux/BSD发行版的软件包的过程.

Most Linux distributions seem to be using start-stop-daemon within init scripts now, but you're still going to have minor difference in filesystem layout and big differences in packaging. Using autotools/configure, or distutils/easy_install if your project is all Python, will go a long way to making it easier to build packages for different Linux/BSD distributions.

Windows是一款完全不同的游戏,需要 Mark Hammond的win32 扩展名,可能还需要 Tim Golden的WMI 扩展.

Windows is a whole different game and will require Mark Hammond's win32 extensions and maybe Tim Golden's WMI extensions.

除了以上都不是"外,我不知道是否已启动.

I don't know Launchd except that "none of the above" are relevant.

有关守护Python脚本的技巧,我希望看看在现实世界中实际正在使用的Python应用程序,例如在Twisted内部.

For tips on daemonizing Python scripts, I would look to Python apps that are actually doing it in the real world, for example inside Twisted.

这篇关于Python守护程序打包最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆