Skip to content

Instantly share code, notes, and snippets.

@tingletech
Last active August 29, 2015 14:02
Show Gist options
  • Save tingletech/9c0e0970f3c33f21e313 to your computer and use it in GitHub Desktop.
Save tingletech/9c0e0970f3c33f21e313 to your computer and use it in GitHub Desktop.
#!/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])
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