Skip to main content

Daemon application help functions.

Project description

daemon-application

Daemon application help functions.

Install

pip install daemon-application

Usage

Example for raw apis

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)

Example for DaemonApplication

import time
from daemon_application import DaemonApplication

class HelloApplication(DaemonApplication):
    def main(self):
        while True:
            print("hello")
            time.sleep(1)

controller = HelloApplication().get_controller()

if __name__ == "__main__":
    controller()

Release

v0.3.2 2020/11/22

  • Add click deps in requirements.txt

v0.3.1 2020/11/22

  • Add DaemonApplication.

v0.3.0 2020/11/21

  • New wrapper.

v0.2.1 2018/04/18

  • Old releases.

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

Uploaded Source

File details

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

File metadata

  • Download URL: daemon-application-0.3.2.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for daemon-application-0.3.2.tar.gz
Algorithm Hash digest
SHA256 7bc51976596c042493304ead8f93d27eb5764619bee16b76f7860b484ad5b4fc
MD5 bb3918038ee0ccc13c47f8a730ddc9b1
BLAKE2b-256 0bb1aa285ba351954f60de5474dd6ed7f73e2d1d37f6b2d9a9265d35138c5a3f

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