33
|
1 # -*- coding: utf-8 -*-
|
|
2
|
|
3 # daemon/__init__.py
|
|
4 # Part of ‘python-daemon’, an implementation of PEP 3143.
|
|
5 #
|
|
6 # Copyright © 2009–2015 Ben Finney <ben+python@benfinney.id.au>
|
|
7 # Copyright © 2006 Robert Niederreiter
|
|
8 #
|
|
9 # This is free software: you may copy, modify, and/or distribute this work
|
|
10 # under the terms of the Apache License, version 2.0 as published by the
|
|
11 # Apache Software Foundation.
|
|
12 # No warranty expressed or implied. See the file ‘LICENSE.ASF-2’ for details.
|
|
13
|
|
14 """ Library to implement a well-behaved Unix daemon process.
|
|
15
|
|
16 This library implements the well-behaved daemon specification of
|
|
17 :pep:`3143`, “Standard daemon process library”.
|
|
18
|
|
19 A well-behaved Unix daemon process is tricky to get right, but the
|
|
20 required steps are much the same for every daemon program. A
|
|
21 `DaemonContext` instance holds the behaviour and configured
|
|
22 process environment for the program; use the instance as a context
|
|
23 manager to enter a daemon state.
|
|
24
|
|
25 Simple example of usage::
|
|
26
|
|
27 import daemon
|
|
28
|
|
29 from spam import do_main_program
|
|
30
|
|
31 with daemon.DaemonContext():
|
|
32 do_main_program()
|
|
33
|
|
34 Customisation of the steps to become a daemon is available by
|
|
35 setting options on the `DaemonContext` instance; see the
|
|
36 documentation for that class for each option.
|
|
37
|
|
38 """
|
|
39
|
|
40 from __future__ import (absolute_import, unicode_literals)
|
|
41
|
|
42 from .daemon import DaemonContext
|
|
43
|
|
44
|
|
45 # Local variables:
|
|
46 # coding: utf-8
|
|
47 # mode: python
|
|
48 # End:
|
|
49 # vim: fileencoding=utf-8 filetype=python :
|