{ "info": { "author": "Todd Francis DeLuca", "author_email": "todddeluca@yahoo.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5" ], "description": "\n## Introduction\n\nMy first introduction to running a command as a daemon looked like this:\n\n nohup mycommand --myoption myarg >/dev/null 2>/dev/null &\n\nWhile this is a good for doing some development work, a proper daemon requires\nquite a number of other things to happen. The wikipedia page\nhttp://en.wikipedia.org/wiki/Daemon\\_(computing) says the following needs to\nhappen:\n\n- Dissociating from the controlling tty\n- Becoming a session leader\n- Becoming a process group leader\n- Executing as a background task by forking and exiting (once or twice). This\n is required sometimes for the process to become a session leader. It also\n allows the parent process to continue its normal execution.\n- Setting the root directory (\"/\") as the current working directory so that the\n process does not keep any directory in use that may be on a mounted file\n system (allowing it to be unmounted).\n- Changing the umask to 0 to allow open(), creat(), et al. operating system\n calls to provide their own permission masks and not to depend on the umask of\n the caller\n- Closing all inherited files at the time of execution that are left open by\n the parent process, including file descriptors 0, 1 and 2 (stdin, stdout,\n stderr). Required files will be opened later.\n- Using a logfile, the console, or /dev/null as stdin, stdout, and stderr\n\nAdditionally, when running a process under monit or initd, it is typical for\nthe process id of the daemon to be stored in a file, so the daemon can be\nmonitored and killed easily.\n\nFinally, it is common to use `start`, `stop`, `restart`, and\n`status` commands to control the daemon.\n\nDaemoncmd takes care of creating a daemon the right way, putting its pid in\na file, and interacting with the daemon via `start`, `stop`, etc. commands.\nUsing it is as simple as:\n\n /path/to/daemoncmd start --pidfile /tmp/mydaemon.pid /path/to/mycommand\n\nSee the Usage section for more details.\n\nFor more information on daemons and daemons in python, see:\n\n- http://pypi.python.org/pypi/python-daemon\n- http://www.python.org/dev/peps/pep-3143/\n- http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66012\n- http://en.wikipedia.org/wiki/Daemon\\_(computing)\n\n\n## Alternatives\n\nHere are some projects that are similar in scope to daemoncmd:\n\n- http://pypi.python.org/pypi/zdaemon/2.0.4, and see\n http://ridingpython.blogspot.cz/2011/08/turning-your-python-script-into-linux.html\n for a description.\n- https://github.com/indexzero/forever\n\nWhile daemoncmd is a great way to start running a daemon, there are many\nprograms designed to run and monitor processes in a way that is more robust and\nfull-featured than simply starting your own daemon. Here is a list of some of\nthem (see http://news.ycombinator.com/item?id=1368855 for a discussion):\n\n- launchd http://launchd.macosforge.org/\n- upstart http://upstart.ubuntu.com/\n- monit http://mmonit.com/monit/\n- supervisord http://supervisord.org/\n- daemontools http://cr.yp.to/daemontools.html\n- daemonize http://bmc.github.com/daemonize/\n- runit http://smarden.sunsite.dk/runit/\n- perp http://b0llix.net/perp/\n\nFor production systems, I recommend using a tool like one of these. I have\nused supervisord and monit before. Some of these tools work with daemons, like\nmonit, in which case daemoncmd could come in handy. Other tools, like\nsupervisord, can supervise your process in such a way that you do not need to\ndaemonize it.\n\n\n## Contribute\n\nIf this project does not do what you want, please open an issue or a pull\nrequest on github, https://github.com/todddeluca/daemoncmd.\n\n\n## Requirements\n\n- Probably Python 2.7 (since that is the only version it has been tested with.)\n\n\n## Installation\n\n### Install from pypi.python.org\n\nDownload and install daemoncmd:\n\n pip install daemoncmd\n\n### Install from github.com\n\nClone and install daemoncmd:\n\n git clone git@github.com:todddeluca/daemoncmd.git\n cd daemoncmd\n python setup.py install\n\n\n## Usage\n\nThis module has two separate uses cases: \n \n- running a command as a daemon process\n- forking the current python process as a daemon.\n\nDaemonizing a command allows one to start, stop, and restart a non-daemon\ncommand as a daemon process. This requires specifying a pid file which is used\nto interact with the process.\n\nUsage examples:\n\n daemoncmd start --pidfile /tmp/daemon.pid \\\n --stdout /tmp/daemon.log --stderr /tmp/daemon.log sleep 100\n daemoncmd restart --pidfile /tmp/daemon.pid \\\n --stdout /tmp/daemon.log --stderr /tmp/daemon.log sleep 100\n daemoncmd status --pidfile /tmp/daemon.pid\n daemoncmd stop --pidfile /tmp/daemon.pid\n\nAnother use case is forking the current process into a daemon. According\nto pep 3143, forking as a daemon might be done by the standard library some\nday.\n\nUsage example:\n\n import daemoncmd\n import mytask\n\n daemoncmd.daemonize()\n mytask.doit()\n\nOr from the command line:\n\n python -c 'import daemoncmd, mytask; daemoncmd.daemonize(); mytask.doit()'\n\nOther usage notes:\n\n- The command should not daemonize itself, since that is what this script does\n and it would make the pid in the pidfile incorrect.\n- The command should refer to the absolute path of the executable, since\n daemonization sets the current working directory (cwd) to '/'. More\n generally, do not assume what the cwd is.\n- If daemoncmd is run by monit, etc., PATH and other env vars might be\n restricted for security reasons.\n- daemoncmd does not try to run the daemon as a particular uid. That would\n be handled by a process manager like monit, launchd, init, god, etc.\n- When running under monit, etc., pass environment variables to the command\n like so:\n\n FOO=testing daemoncmd start --pidfile /tmp/daemon.pid \\\n --stdout /tmp/daemon.log printenv FOO\n\n\n\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/todddeluca/daemoncmd", "keywords": "daemon python cli init nohup commandline executable script pidfile", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "daemonpy3", "package_url": "https://pypi.org/project/daemonpy3/", "platform": "", "project_url": "https://pypi.org/project/daemonpy3/", "project_urls": { "Homepage": "https://github.com/todddeluca/daemoncmd" }, "release_url": "https://pypi.org/project/daemonpy3/1.0.3/", "requires_dist": null, "requires_python": "", "summary": "Turn any command line into a daemon with a pidfile", "version": "1.0.3" }, "last_serial": 3627344, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "b982ba20958391673dcb48ad21da7028", "sha256": "ec443e0a6c6f835dafbc2102db39bb08c628298a889993036c3cff2f2fa734da" }, "downloads": -1, "filename": "daemonpy3-1.0.0.tar.gz", "has_sig": false, "md5_digest": "b982ba20958391673dcb48ad21da7028", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7199, "upload_time": "2018-01-10T08:46:26", "url": "https://files.pythonhosted.org/packages/6d/4b/10a9f0a4a3be00a2539330e267490375247afc1a185fe5f66d459ca4cfee/daemonpy3-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "997a5cdb1903dc45d03ac44f7335e32a", "sha256": "e85e500ce939cf5c79587eb7a50c37a93c65335a4e946d6218f9208acf5867d9" }, "downloads": -1, "filename": "daemonpy3-1.0.1.tar.gz", "has_sig": false, "md5_digest": "997a5cdb1903dc45d03ac44f7335e32a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6935, "upload_time": "2018-01-10T10:48:57", "url": "https://files.pythonhosted.org/packages/94/45/b5056a9a70196e6cc98a120251e29ba78255f0405f69c0957815595960c9/daemonpy3-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "e9d001f2cd25d05c4b5fbef5df396240", "sha256": "0c816ddf1bb4ca7aa3368ff91a2bf51c243ec147383f1e4d2934cdcb2f6316fa" }, "downloads": -1, "filename": "daemonpy3-1.0.2.tar.gz", "has_sig": false, "md5_digest": "e9d001f2cd25d05c4b5fbef5df396240", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6926, "upload_time": "2018-01-10T14:01:02", "url": "https://files.pythonhosted.org/packages/06/2f/531cf0d1e599b36129650b4c6449e54c2fcdddcc50e042cc5468abb6e392/daemonpy3-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "cddb0609978e25bf8be5931de313fda6", "sha256": "d82e2b8bfd347b44bfe5a7075ab60180a1168fa7a723b6ec3d1623da38801e6e" }, "downloads": -1, "filename": "daemonpy3-1.0.3.tar.gz", "has_sig": false, "md5_digest": "cddb0609978e25bf8be5931de313fda6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6989, "upload_time": "2018-03-01T03:20:10", "url": "https://files.pythonhosted.org/packages/6c/10/da327e7d400b112604ac35d6de27410922de0c255c94464a231d8ffc1284/daemonpy3-1.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "cddb0609978e25bf8be5931de313fda6", "sha256": "d82e2b8bfd347b44bfe5a7075ab60180a1168fa7a723b6ec3d1623da38801e6e" }, "downloads": -1, "filename": "daemonpy3-1.0.3.tar.gz", "has_sig": false, "md5_digest": "cddb0609978e25bf8be5931de313fda6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6989, "upload_time": "2018-03-01T03:20:10", "url": "https://files.pythonhosted.org/packages/6c/10/da327e7d400b112604ac35d6de27410922de0c255c94464a231d8ffc1284/daemonpy3-1.0.3.tar.gz" } ] }