Skip to main content

Daemon application help functions.

Project description

https://travis-ci.org/appstore-zencore/daemon-application.svg?branch=master

Daemon application help functions.

Install

pip install daemon-application

Usage

import time
import threading
import signal
from daemon_application import daemon_start

stopflag = False

def main():
    def on_exit(*args, **kwargs):
        with open("backgroud.log", "a", encoding="utf-8") as fobj:
            print("process got exit signal...", file=fobj)
            print(args, file=fobj)
            print(kwargs, file=fobj)
        global stopflag
        stopflag = True
    signal.signal(signal.SIGTERM, on_exit)
    signal.signal(signal.SIGINT, on_exit)
    while not stopflag:
        time.sleep(1)
        print(time.time())

if __name__ == "__main__":
    print("start background application...")
    daemon_start(main, "background.pid", True)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

daemon-application-0.2.1.tar.gz (3.6 kB view details)

Uploaded Source

File details

Details for the file daemon-application-0.2.1.tar.gz.

File metadata

File hashes

Hashes for daemon-application-0.2.1.tar.gz
Algorithm Hash digest
SHA256 452a19d691da8cc47e6decd2b2e845244584a7a88aa877037d05c28cd45dcb2e
MD5 104bd543381e940afd8ca57522876abc
BLAKE2b-256 80dddf6d13038805b28c352ab74c054f332c1063515c1f281881e584235cc016

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page