Created
September 3, 2019 08:12
-
-
Save tyaslab/790550bf5ca70bfa5c6ddaae940421fd to your computer and use it in GitHub Desktop.
Daemonize
This file contains 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
import time | |
import logging | |
from daemonize import Daemonize | |
pid = "/tmp/test.pid" | |
logger = logging.getLogger(__name__) | |
logger.setLevel(logging.DEBUG) | |
logger.propagate = False | |
fh = logging.FileHandler("/tmp/test.log", "w") | |
fh.setLevel(logging.DEBUG) | |
logger.addHandler(fh) | |
keep_fds = [fh.stream.fileno()] | |
def main(): | |
while True: | |
time.sleep(60) | |
logger.debug("Test") | |
daemon = Daemonize(app="test_app", pid=pid, action=main, keep_fds=keep_fds) | |
daemon.start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment