Python守护程序打包最佳实践

编程入门 行业动态 更新时间:2024-10-23 15:20:52
本文介绍了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守护程序打包最佳实践

本文发布于:2023-05-29 23:07:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/355051.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:程序   Python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!