daemonim

daemonizer for Unix, Linux and OS X

Pure Nim score 30/100 · tests present · docs generated

Summary

Latest Version Unknown
License MIT
CI Status Passing
Downloads 0
Last Indexed 2026-07-21 05:24

Tags

Installation

nimble install daemonim
choosenim install daemonim
git clone https://github.com/bung87/daemon

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
daemonim - - - - - - -

Source

Repository https://github.com/bung87/daemon
Homepage https://github.com/bung87/daemon
Documentation View Documentation
Registry Source nimble_official

README

daemonim

This package that will daemonize your program so it can continue running in the background. It works on Unix, Linux and OS X, creates a PID file and has standard commands (start, stop, restart) .

Based on python-daemon

see also PEP 3143

Usage

    import daemonim
    import os
    const
        DEVNULL = "/dev/null"
    var d = initDaemon("/tmp/daemonim.pid",open(DEVNULL,fmRead),open(DEVNULL,fmAppend),open(DEVNULL,fmAppend))
    daemonize(d):
        echo d.pidfile
        while true:
            echo d.is_running()
            sleep(2000)

or

    import daemonim
    import os
    const
        defaultAppName = "daemonim"
        STD_ERR_LOG = "$#-stderr.log" % defaultAppName
        STD_OUT_LOG = "$#-stdout.log" % defaultAppName
        STD_IN_LOG = "$#-stdin.log" % defaultAppName

    var d2 = initDaemon(defaultPidPath,STD_IN_LOG,STD_OUT_LOG,STD_ERR_LOG)
    # or var d2 = initDaemon(defaultPidPath)
    daemonize(d2):
        echo d2.pidfile
        while true:
            echo d2.is_running()
            sleep(2000)

Actions

  • start() - starts the daemon (creates PID and daemonizes).
  • stop() - stops the daemon (stops the child process and removes the PID).
  • restart() - does stop() then start().