FastNetMon

Monday 22 December 2014

Демонизация процессов на CentOS и Debian

Задача весьма мерзкая. Особенно когда нужно выбрать унифицированное решение, удовлетворяющее обе платформы.

Для Debian есть пакет daemon.

Вот с таким набором параметров:
daemon
Invalid arguments: no command supplied
usage: daemon [options] [--] [cmd arg...]
options:

      -h, --help              - Print a help message then exit
      -V, --version           - Print a version message then exit
      -v, --verbose[=level]   - Set the verbosity level
      -d, --debug[=level]     - Set the debugging level

      -C, --config=path       - Specify the configuration file
      -N, --noconfig          - Bypass the system configuration file
      -n, --name=name         - Guarantee a single named instance
      -X, --command=cmd       - Specify the client command as an option
      -P, --pidfiles=/dir     - Override standard pidfile location
      -F, --pidfile=/path     - Override standard pidfile name and location

      -u, --user=user[:group] - Run the client as user[:group]
      -R, --chroot=path       - Run the client with path as root
      -D, --chdir=path        - Run the client in directory path
      -m, --umask=umask       - Run the client with the given umask
      -e, --env="var=val"     - Set a client environment variable
      -i, --inherit           - Inherit environment variables
      -U, --unsafe            - Allow execution of unsafe executable
      -S, --safe              - Deny execution of unsafe executable
      -c, --core              - Allow core file generation

      -r, --respawn           - Respawn the client when it terminates
      -a, --acceptable=#      - Minimum acceptable client duration (seconds)
      -A, --attempts=#        - Respawn # times on error before delay
      -L, --delay=#           - Delay between spawn attempt bursts (seconds)
      -M, --limit=#           - Maximum number of spawn attempt bursts
          --idiot             - Idiot mode (trust root with the above)

      -f, --foreground        - Run the client in the foreground
      -p, --pty[=noecho]      - Allocate a pseudo terminal for the client

      -l, --errlog=spec       - Send daemon's error output to syslog or file
      -b, --dbglog=spec       - Send daemon's debug output to syslog or file
      -o, --output=spec       - Send client's output to syslog or file
      -O, --stdout=spec       - Send client's stdout to syslog or file
      -E, --stderr=spec       - Send client's stderr to syslog or file

          --running           - Check if a named daemon is running
          --restart           - Restart a named daemon client
          --stop              - Terminate a named daemon process


Для  CentOS есть пакет daemonize.

Вот с таким набором параметров:
 daemonize
daemonize, version 1.7.3
Usage: daemonize [OPTIONS] path [arg] ...

OPTIONS

-a             Append to, instead of overwriting, output files. Ignored
               unless -e and/or -o are specified.
-c <dir>       Set daemon's working directory to <dir>.
-e <stderr>    Send daemon's stderr to file <stderr>, instead of /dev/null.
-E var=value   Pass environment setting to daemon. May appear multiple times.
-o <stdout>    Send daemon's stdout to file <stdout>, instead of /dev/null.
-p <pidfile>   Save PID to <pidfile>.
-u <user>      Run daemon as user <user>. Requires invocation as root.
-l <lockfile>  Single-instance checking using lockfile <lockfile>.
-v             Issue verbose messages to stdout while daemonizing.
Такое ощущение, что лучше демонизироваться самому.

2 comments :

  1. Паша, если процесс python - посмотри в сторону supervisor, полезная штука

    ReplyDelete
    Replies
    1. У меня Питона нету, а где был - выпилен :) Ибо терпеть его лаги - это не особо приятное удовольствие =)

      Delete

Note: only a member of this blog may post a comment.