Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A process respawner for people who want syslogging and reliable behavior
C
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src
test
DEPLOYING
MIT-LICENSE
Makefile
README

README

Niet, a process respawner for people who want syslogging and reliable behavior
==============================================================================


Usage: niet /usr/bin/someprogram foo bar
          - Runs someprogram with the arguments 'foo' and 'bar', restarting the
            program again if it dies, waiting for up to 60s if it's dying in
            less than 60s to prevent the program spinning its wheels.  Sends
            output from the program on its stdout and stderr to syslog using
            `logger` with appropriate priorities.  If sent a TERM signal, sends
            a TERM signal to the program, waits for it to finish, and then
            restarts it.  If sent a QUIT signal, sends a TERM signal to the
            program, waits for it to finish, and then quits.

            niet requires no privileges and should be run as the user you want
            to run the daemon under.  It can be run as root, but running your
            software as root is generally discouraged.

Options: -o daemon.notice  Changes the log priority of the syslog messages
                           logged from the program's stdout to 'daemon.notice'.
                           Default: user.info.
         -e daemon.alert   Changes the log priority of the syslog messages
                           logged from the program's stderr to 'daemon.alert'.
                           Default: user.err.
         -t syslog_tag     Changes the syslog tag of the syslog messages logged
                           from the program's stdout & stderr to 'syslog_tag'.
                           Default: the executed program name.
         -k 15             Sets a timeout of 15 seconds after the program is
                           sent a TERM signal, after which it will be killed by
                           a KILL signal.
                           Default: no KILL signal.
         -p /var/run/x.pid Writes the PID of this process to /var/run/x.pid.
                           Default: no PID file.
                           The use of PID files is discouraged: they're just
                           another thing to go wrong.  niet is designed to be
                           controlled entirely using signals, which you can use
                           without PID files.  See DEPLOYING for examples.
         -c /cd/to/here    Changes to this directory before running the command.
                          Default: /.


Installation
============

To compile niet and install it to /usr/local/bin (which is usually already on
your PATH), run:

	make && sudo make install

To install it to /usr/bin instead, run:

   make && sudo make install_to_usr_bin


Deploying application daemons with niet
=======================================

See DEPLOYING.


Non-features
============

Niet does not:

 - need to run as root

 - make or listen on sockets or IPC channels of any kind

 - have a complex and buggy process lifecycle

 - fill your logs and use your CPU spinning around restarting the program
   rapidly if it's repeatedly failing (it'll wait (60s - the time the last run
   survived for), eg. 50s if the program lasted 10s; so it won't wait if the
   program survived at least a minute, and it won't wait when you signal it
   to restart the program)

 - give up starting the program (datacentre clusters frequently take >30
   minutes to become fully operational if the database server fscks when the
   power comes back on)

 - mess about with logfiles (niet is for people with multiple servers, who like
   syslog - try supervisord if you want logfiles).

 - send you notifications (you should have alerting on your syslogs so you can
   see errors from everything); niet will log all 'business as usual' messages,
   including requested restarts, at the 'normal' priority, and all 'not business
   as usual' messages, including unexpected app crashes and any app output on
   STDERR, at the 'error' priority; you can customize these using the above
   options.

 - poll and restart your program if it's using too much memory (your operating
   system can automatically limit a program's memory use, without polling - use
   ulimit)

 - poll and restart your program if it's using too much CPU (you want your app
   to crash when there's a lot of work on?  use something else, also learn to
   code)

 - monitor the state of your server (niet is for processes - try munin)


License
=======

MIT.
Something went wrong with that request. Please try again.