Skip to main content

painless per-user daemon manager

Project description

nocrux is a painless per-user daemon manager that is easily configured with a Python 3 script in the users home directory. It supports many of the common settings to start daemon processes such as redirecting stdout/stderr, pidfiles (required), additional arguments, process current working directory and more.

EXAMPLE CONFIGURATION

The configuration file for nocrux must be in ~/nocrux_config.py.

root_dir = expanduser('~/.nocrux')  # default
kill_timeout = 10  # default
register_daemon(
  name = 'test',
  prog = expanduser('~/Desktop/my-daemon.sh'),
  args = [],      # default
  cwd  = '~',     # default, automatically expanded after setting user ID
  user = None,    # name of the user, defaults to current user
  group = None,   # name of the group, defaults to current user group
  stdin = None,   # stdin file, defaults to /dev/null
  stdout = None,  # stdout file, defaults to ${root_dir}/${name}.out
  stderr = None,  # stderr file, defaults to stdout
  pidfile = None, # pid file, defaults to ${root_dir}/${name}.pid
  requires = [],  # default, list of daemon names that need to run before this
)

COMMANDLINE INTERFACE

usage: nocrux [-h] [-e] {version,start,stop,restart,status,fn:out,fn:err,fn:pid}
              [daemon [daemon ...]]

positional arguments:
  {version,start,stop,restart,status,fn:out,fn:err,fn:pid}
  daemon                name of one or more daemons to interact with. the
                        special name'all' can be used to refer to all
                        registered daemons

optional arguments:
  -h, --help            show this help message and exit
  -e, --stderr          display stderr rather than stdout. only used for the
                        'tail' command

Example:

$ nocrux start test
[nocrux]: (test) starting "/home/niklas/Desktop/daemon.sh"
[nocrux]: (test) started. (pid: 3203)
$ nocrux status all
[nocrux]: (test) started
$ nocrux tail test
daemon.sh started
[nocrux]: (test) terminated. exit code: -15
daemon.sh started
[nocrux]: (test) terminated. exit code: -15
daemon.sh started
[nocrux]: (test) terminated. exit code: -15
daemon.sh started
daemon.sh ended
[nocrux]: (test) terminated. exit code: 0
daemon.sh started
^C$ nocrux stop all
[nocrux]: (test) stopping... done

INSTALLATION

pip install nocrux

REQUIREMENTS

  • Python 3

  • Unix-like operating system (tested on Ubuntu 15.05, Mac OS X El Capitan)

  • Pandoc when installing from the Git repository (not required for Pip installation)

CHANGELOG

v1.1.2 (unreleased)

  • add setup.py installation script, remove nocrux script

  • update README.md and renamed from README.markdown

v1.1.1

  • close #18: Automatically expand prog ~ before starting process

  • fix #17: PID file not deleted after daemon stopped

  • close #16: Tail command is counter intuitive

  • update output of command-line program

  • process exit code is now printed to daemon standard error output file

  • fixed stopping multiple daemons when one wasn’t running

  • implement #10: daemon dependencies

v1.1.0

  • Renamed to nocrux

  • Update README and command-line help description

v1.0.1

  • Add krugs tail <daemon> [-e/-stderr] command

  • Add special deaemon name all

  • Fix krugs restart command

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

nocrux-1.1.2.zip (7.3 kB view hashes)

Uploaded Source

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