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.0.tar.gz (3.6 kB view details)

Uploaded Source

File details

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

File metadata

File hashes

Hashes for daemon-application-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4eae654036a6b5f5f77204d5956360dcaefe2a89782b40294ba2b795ac155e7a
MD5 daf5938db19bdeeb9ad7c37a074934e7
BLAKE2b-256 8f6c38c0496100b177d8ae5ab2cf10406b3b25c5ec09815bc30d007de9dbe71e

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