Bug 835947 - [RFE] rlDaemonize - daemonize a given command
[RFE] rlDaemonize - daemonize a given command
Product: Fedora
Classification: Fedora
Component: beakerlib (Show other bugs)
Unspecified Unspecified
medium Severity medium
: ---
: ---
Assigned To: Dalibor Pospíšil
Fedora Extras Quality Assurance
: Patch
Depends On:
Blocks: 1333921
  Show dependency treegraph
Reported: 2012-06-27 11:42 EDT by Jiri Jaburek
Modified: 2016-09-19 22:11 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
[PATCH] daemonize.py: added, backend for rlDaemonize (6.29 KB, patch)
2012-06-27 11:42 EDT, Jiri Jaburek
no flags Details | Diff

  None (edit)
Description Jiri Jaburek 2012-06-27 11:42:08 EDT
Created attachment 594819 [details]
[PATCH] daemonize.py: added, backend for rlDaemonize

  rlDaemonize [options] "command arg1 arg2 arg3"

rlDaemonize is a python script able to fork / fully daemonize any given command. It uses fork and execvp, it is therefore able to easily use commands in PATH.

Bash "jobs" are not well suited for daemonization - they are overly verbose when spawning / terminating a job (which is a problem with thousands of jobs) and they don't support full daemonization (double fork, setsid, ...) when it's needed. Furthermore, syntax to achieve more complex scenario (ie. pidfile + run as another user + redirect stdio) is very complex.

Common use case for rlDaemonize would be spawning ie. systemtap as daemon, with stdio redirected to log file(s).

The main (python) part with input sanity checks is finished, attached as a patch against latest beakerlib/master, however the bash wrapper part is missing, since I'm unsure how it should be done.
Note that daemonize.py expects command for daemonization with all its arguments as a single command line argument, just like the rlRun function.

$ ./daemonize.py --help
Usage: daemonize.py [options] COMMAND

  -h, --help            show this help message and exit
  --alias=NAME          specify custom argv[0]
  --background          background (fork) only, nothing else
  --su=USER:GROUP       run daemon under another user
  --ioredir=IN,OUT,ERR  redirect std{in,out,err} of the daemon to files
  --pidfile=FILE        write daemon pid to a file

Note You need to log in before you can comment on or make changes to this bug.