Package: nocrux
Nocrux is an easily configurable daemon manager that can be used by any
user on the system. It uses double-forks to transfer cleanup
responsibility of daemons to the init process.SynopsisRequirementsInstallationA note about child processesA note about managing daemons under a different
userChangelogSynopsisusage: nocrux [-h] [-e] [-l] [-f] [--sudo] [--as AS_] [--stderr] [--version]
              [daemon] [command]

  Nocrux is a daemon process manager that is easy to configure and can
  operate on the user- or root-level. The nocrux configuration syntax is
  similar to Nginx. All users configuration file is in ~/.nocrux/conf,
  except for the root user, which is in /etc/nocrux/conf.

  This will start your $EDITOR to open the configuration file:

      $ nocrux -e

  The main namespace has the options and default values below:

      root ~/.nocrux/run;
      kill_timeout 10;

  You can also include other files like this (relative paths are considered
  relative to the configuration file):

      include ~/more-nocrux-config.txt;

  To configure a new daemon, you start a `daemon` section, specify the name
  and then the daemon's options in the news scope.

      daemon jupyter {
        cwd ~;
        run jupyter notebook;
      }

  You can now start the daemon with:

      $ nocrux jupyter start
      [nocrux]: (jupyter) starting "jupyter notebook"
      [nocrux]: (jupyter) started (pid: 10117)

  The following commands are available for all daemons:

    - start
    - stop
    - restart
    - status
    - pid
    - cat
    - tail

  You can specify additional commands like this:

      daemon jupyter {
        cwd ~;
        run jupyter notebook;
        command uptime echo $(($(date +%s) - $(date +%s -r $DAEMON_PIDFILE))) seconds;
      }

  Now to run this command:

      $ nocrux jupyter uptime;
      3424 seconds;

  Here's a daemon configuration with all available options and the
  respective default or example values:

      daemon test {
        # Example values:
        export PATH=/usr/sbin:$PATH;
        export DEBUG=1;
        run ~/Desktop/mytestdaemon.sh arg1 "arg 2";
        cwd ~;
        command uptime echo $(($(date +%s) - $(date +%s -r $DAEMON_PIDFILE))) seconds;
        requires daemon1 daemon2;

        # Options with their respective defaults:
        user me;
        group me;
        stdin /dev/null;
        stdout $root/$name.out;
        stderr $stdout;
        pidfile $root/$name.pid;
        signal term TERM;
        signal kill KILL;
      }

positional arguments:
  daemon        The name of the daemon.
  command       A command to execute on the specified daemon.

optional arguments:
  -h, --help    show this help message and exit
  -e, --edit    Edit the nocrux configuration file.
  -l, --list    List up all daemons and their status.
  -f, --follow  Pass -f to the tail command.
  --sudo        Re-invoke the same command with sudo.
  --as AS_      Run the command as the specified user. Overrides --sudo.
  --stderr      Choose stderr instead of stdout for the cat/tail command.
  --version     Print the nocrux version and exit.RequirementsUnix-like OS (tested on Ubuntu 15-17, Debian Jessie, macOS Sierra)Python 3.4+Node.py(optional)Installation$ pip3 install --user nocrux    # or
$ nodepy-pm install git+https://github.com/NiklasRosenstein/nocrux.git@v2.0.3 --globalA note about child processesNocrux can only send SIGTERM or SIGKILL to themain processthat it
originally started. If that process spawns any child precesses, it must
take care of forwarding the signal! The thread*Forward SIGTERM to
child in Bash*contains some information on doing that for Bash scripts. For very
simple scripts that just set up an environment, I recommend theexecapproach as described in the link.A note about managing daemons under a different userExample:daemon gogs {
  user gogs;
  cwd /home/gogs/gogs;
  run ./gogs web;
}If you’re trying to manage a daemon that will be started by nocrux under
a different user, you need the permissions to do so. For example, the
superuser is allowed to do so and using nocrux as root should work
immediately.However, if you are not already the root user, nocrux will by default
try to re-run itself as the user specified in the daemon, eg. in this
case:sudo gogs NOCRUX_CONFIG=/home/niklas/.nocrux/conf /home/niklas/.local/bin/nocrux gogs startThis will only work ifYou installed nodepy system-wide,oryou installed it with
Node.py and thegogsuser can read the path of the nocrux
executable and the nocrux package directoryThegogsuser can read your nocrux configuration fileOtherwise, you may be greeted with one of the following error messages:sudo: unable to execute /home/niklas/.local/bin/nocrux: Permission
deniedpkg_resources.DistributionNotFound: The ‘nocrux==2.0.3’ distribution
was not found and is required by the applicationModuleNotFoundError: No module named ‘nodepy’Changelogv2.0.3Update for Node.py 2Add--sudocommand-line optionAdd--as<user>command-line optionAdd support for variable substition in thedaemon { export; }fieldAdd support for custom signals for termination and killing a daemon
process (see issue #21)Add support for custom daemon subcommands that have access to the
following environment variables:$DAEMON_PID,$DAEMON_PIDFILE,$DAEMON_STDOUT,$DAEMON_STDERR(see
issue #22)Add support fordaemon{ root; }field which will change the
parent directory of the default paths for the PID and standard output
filesAdd support for#comments in the configuration fileChange behaviour ofdaemon { user; }option, now serves as a
default value for the--asoptionFix configuration loading (daemon { run; }may now be preceeded
by any other option)Fix-e,--editnow opens the editor always for the user’s filev2.0.2fixnocrux versioncommandaddnocrux editcommandorder of daemons when referencing them withallis now sorted
alphabeticallyv2.0.1removedfn:out,fn:errandfn:pidcommands (actually
already removed in 2.0.0)the defaultrootconfig value will now be/var/run/nocruxif
the configuration file is loaded from/etc/nocrux/confmore sophisticated config file parsing withnr.parse.strexmoduleupdate error message hinting to check output ofnocrux <daemon> tailif daemon could not be startedv2.0.0cli is nownocrux <daemon> <command>(switched)to specify multiple daemons, the<daemon>argument can be a list
of comma separated daemon namesconfiguration file is no longer a Python scriptconfiguration file must now be located at~/.nocrux/confor/etc/nocrux/confnocrux can now be installed via Node.pyadd support for defining per-process environment variablesv1.1.3updateREADME.md(corrected example and command-line interface)remove unusued-e,--stderrargumentfixsetup.py(usepy_modulesinstead of the invalidmodulesparameter)enable runningnocrux.pydirectly without prior installationaddpid,tail,tail:outandtail:errsubcommandsv1.1.2addsetup.pyinstallation script, removenocruxscriptupdateREADME.mdand renamed fromREADME.markdownv1.1.1close #18: Automatically expand prog ~ before starting processfix #17: PID file not deleted after daemon stoppedclose #16: Tail command is counter intuitiveupdate output of command-line programprocess exit code is now printed to daemon standard error output filefixed stopping multiple daemons when one wasn’t runningimplement #10: daemon dependenciesv1.1.0Renamed tonocruxUpdate README and command-line help descriptionv1.0.1Addkrugs tail <daemon>[-e/-stderr]commandAdd special deaemon nameallFixkrugs restartcommand