Skip to content

Instantly share code, notes, and snippets.

@quasoft
Created October 9, 2016 17:12
Show Gist options
  • Save quasoft/0143656abc445b4ea1b839c8b2fa264c to your computer and use it in GitHub Desktop.
Save quasoft/0143656abc445b4ea1b839c8b2fa264c to your computer and use it in GitHub Desktop.
Example on using daemonize module in Python
#!/usr/bin/env python3
import os
import sys
import time
from daemonize import Daemonize
def main():
while True:
time.sleep(10)
if __name__ == '__main__':
appname=os.path.basename(sys.argv[0])
pidfile='/tmp/mypidfile.pid'
daemon = Daemonize(app=appname,pid=pidfile, action=main)
daemon.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment