Last active
August 29, 2015 14:02
-
-
Save tingletech/9c0e0970f3c33f21e313 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import time | |
import logging | |
import daemonocle | |
from shove import Shove | |
def main(): | |
logging.basicConfig( | |
filename='/tmp/daemonocle_example.log', | |
level=logging.DEBUG, format='%(asctime)s [%(levelname)s] %(message)s', | |
) | |
logging.info('Daemon is starting') | |
logging.debug('1') | |
x = Shove() | |
logging.debug('2') | |
def cb_shutdown(message, code): | |
logging.info('Daemon is stopping') | |
logging.debug(message) | |
if __name__ == '__main__': | |
detach = False if len(sys.argv) > 2 else True | |
daemon = daemonocle.Daemon( | |
worker=main, | |
detach=detach, | |
shutdown_callback=cb_shutdown, | |
pidfile='/tmp/daemonocle_example.pid', | |
) | |
daemon.do_action(sys.argv[1]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from shove import Shove | |
import os | |
x = Shove() | |
newpid = os.fork() | |
if newpid == 0: | |
xx = Shove() | |
print("hey") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment