Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
sohwaje committed May 23, 2021
1 parent 75a575a commit 1d8691e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions daemon_example.py → daemon_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _makeDaemon(self):

try:
pid = os.fork()
if pid > 0:
if pid > 0:
# Exit first parent.
sys.exit(0)
except OSError as e:
Expand All @@ -52,7 +52,7 @@ def _makeDaemon(self):
# Do second fork.
try:
pid = os.fork()
if pid > 0:
if pid > 0:
# Exit from second parent.
sys.exit(0)
except OSError as e:
Expand Down Expand Up @@ -91,7 +91,7 @@ def start(self):

# Handle signals
signal.signal(signal.SIGINT, self._sigterm_handler)
signal.signal(signal.SIGTERM, self._sigterm_handler)
signal.signal(signal.SIGTERM, self._sigterm_handler) # go to null -> si = open(os.devnull, 'r')
signal.signal(signal.SIGHUP, self._reload_handler)

# Check if the daemon is already running.
Expand Down Expand Up @@ -208,12 +208,14 @@ class MyDaemon(Daemon):
def run(self):
x = 10
y = x ** 2
# return y


########################################################################################################################

if __name__ == "__main__":
daemon = MyDaemon()
# print(daemon.run())

usageMessage = "Usage: {} (start|stop|restart|status|reload|version)".format(sys.argv[0])

Expand Down

0 comments on commit 1d8691e

Please sign in to comment.