dmon:dmon.git
12 years agoRelease v0.3 v0.3
Adrian Perez [Thu, 26 Aug 2010 21:06:05 +0000 (23:06 +0200)]
Release v0.3

12 years agoUpdate manual page with the -L/-l options, plus example
Adrian Perez [Thu, 26 Aug 2010 20:59:25 +0000 (22:59 +0200)]
Update manual page with the -L/-l options, plus example

12 years agoFix: SIGSTOP signal must be forwarded with -S/-s
Adrian Perez [Thu, 26 Aug 2010 20:48:21 +0000 (22:48 +0200)]
Fix: SIGSTOP signal must be forwarded with -S/-s

Moved the definition of SIGTOP to the upper part of the forward_signals
array, so the signal handler is installed for it as well. This fixes that
signal not being forwarded to the child processes.

12 years agoImplement process pause/resume depending on load average
Adrian Perez [Thu, 26 Aug 2010 20:44:31 +0000 (22:44 +0200)]
Implement process pause/resume depending on load average

Passing the "-L" option will enable load average tracking. Once per second
dmon will check the system's load average, and when it goes over the given
value, it will send SIGSTOP to the main process, effectively pausing it.
Once the load falls below the value specified with "-l" (or half the high
level, if not given) then dmon will send SIGCONT to resume the process.

12 years agoutil: Implement iterruptible_sleep()
Adrian Perez [Thu, 26 Aug 2010 19:12:29 +0000 (21:12 +0200)]
util: Implement iterruptible_sleep()

This is a version of sleep() which does not mess SIGALRM, which can be
interrupted by signals, in which event it will return zero.

12 years agoCategorize help output of dmon
Adrian Perez [Thu, 26 Aug 2010 18:41:07 +0000 (20:41 +0200)]
Categorize help output of dmon

This makes easier to spot which option of process execution/monitorization
one is searching for when invoking the help message with "dmon -h".

12 years agoUpdate manual page with setid/setgid options
Adrian Perez [Wed, 25 Aug 2010 15:35:49 +0000 (17:35 +0200)]
Update manual page with setid/setgid options

This adds the description of the setid/setgid command line options, and an
usage example in the manual page for dmon.

12 years agoImplement setuid/setgid when spawning child processes
Adrian Perez [Wed, 25 Aug 2010 15:18:23 +0000 (17:18 +0200)]
Implement setuid/setgid when spawning child processes

* New "uid" and "gid" fields in task structures.
* Adds options -u/-U/-g/-G for setting user/group credentials, both for main
  command and logging command.
* Master process does not drop privileges. Doing that would make impossible
  for it to respawn child processes with the desired credentials.

12 years agoHelper name_to_uid() & name_to_gid() functions
Adrian Perez [Wed, 25 Aug 2010 00:31:04 +0000 (02:31 +0200)]
Helper name_to_uid() & name_to_gid() functions

Those functions take both a string which may be a number or a user/group
name, and return the associated UID/GID number converted.

12 years agodmon: Do not wait the first time a process is started
Adrian Perez [Wed, 11 Aug 2010 22:05:25 +0000 (00:05 +0200)]
dmon: Do not wait the first time a process is started

Now dmon keeps track of the moment at which a command was started to
determine whether to sleep for 1s before respawning. The initial value
of the variable makes dmon to *not* sleep before executing commands for
first time. This is intended behavior. Using some kind of back-off for
respawns would be nice, but that would involve having an additional
counter, so for the moment this solution is good enough.

12 years agoutil: Handle passing zero to safe_sleep
Adrian Perez [Wed, 11 Aug 2010 21:30:04 +0000 (23:30 +0200)]
util: Handle passing zero to safe_sleep

Return directly when zero is passed. This way we ensure that zero is a valid
value, and for implementations which incur in a system call, it is avoided.

12 years agoRelease v0.2 v0.2
Adrian Perez [Wed, 4 Aug 2010 00:40:46 +0000 (02:40 +0200)]
Release v0.2

12 years agodmon: Sleep second before exec'ing to prevent DoS
Adrian Perez [Wed, 4 Aug 2010 00:35:15 +0000 (02:35 +0200)]
dmon: Sleep second before exec'ing to prevent DoS

This will inconditionally sleep for one second before doing stream
redirection and exec() for spawned childs, to have some time before
fork+exec combos, thus providing some alleviation for possible DoS
attacks.

12 years agoutil: Fix header to say "util" instead of "dmon-util"
Adrian Perez [Wed, 4 Aug 2010 00:17:46 +0000 (02:17 +0200)]
util: Fix header to say "util" instead of "dmon-util"

12 years agodmon: Print error message when no command is specified
Adrian Perez [Tue, 3 Aug 2010 21:01:09 +0000 (23:01 +0200)]
dmon: Print error message when no command is specified

If no command is given in the command line, issue an error and exit instead
of blindly trying to start a null command.

12 years agodmon: Implement timeout for process running time
Adrian Perez [Tue, 3 Aug 2010 20:55:15 +0000 (22:55 +0200)]
dmon: Implement timeout for process running time

When a timeout is specified, with "-t SECONDS", then if the command takes
longer to complete, it will be terminated by sending the SIGTERM/SIGCONT
combo, and then respawned. This can be used to run processes that must be
enforced to keep their running time below a given value.

As a bonus, suffixes for the argument to "-t" may be given: (w)eeks, (d)ays,
(h)ours and (m)inutes.

12 years agodmon: Implement -1 (run once) switch
Adrian Perez [Fri, 30 Jul 2010 21:17:51 +0000 (23:17 +0200)]
dmon: Implement -1 (run once) switch

If the program exits with success code (i.e. zero) it is not respawnd and
dmon will close itself. Otherwise the process is respawned as usual.

12 years agoDebian packaging files v0.1
Adrian Perez [Fri, 30 Jul 2010 04:50:46 +0000 (06:50 +0200)]
Debian packaging files

12 years agoAdd manual page for dmon
Adrian Perez [Fri, 30 Jul 2010 04:39:38 +0000 (06:39 +0200)]
Add manual page for dmon

12 years agodmon: Implement daemonization and PID file writing
Adrian Perez [Fri, 30 Jul 2010 04:12:37 +0000 (06:12 +0200)]
dmon: Implement daemonization and PID file writing

* Now by default dmon will daemonize itself before launching its childs. The
  "-n" option may be passed to stay in foreground.
* The "-p" option is now honored and the PID will be written to the
  specified file.

12 years agodlog: Do not create log file with execution bit set
Adrian Perez [Fri, 30 Jul 2010 03:44:02 +0000 (05:44 +0200)]
dlog: Do not create log file with execution bit set

12 years agoAvoid building debug functions
Adrian Perez [Fri, 30 Jul 2010 03:41:09 +0000 (05:41 +0200)]
Avoid building debug functions

12 years agoImplement signal handling and process respawning
Adrian Perez [Fri, 30 Jul 2010 03:38:50 +0000 (05:38 +0200)]
Implement signal handling and process respawning

* Died processes are now respawned by default.
* Signals can now be passed to both the log command and the main command.
* Children processes are properly reaped.

12 years agoMigrate to new task_t control structure
Adrian Perez [Fri, 30 Jul 2010 02:12:30 +0000 (04:12 +0200)]
Migrate to new task_t control structure

A new task_t data type holds all information related to a process,
and a set of higher-level task_*() functions is added. Apart from
that cleanup, no additional functionality is added.

12 years agoSupport omitting log file path on dlog
Adrian Perez [Fri, 30 Jul 2010 01:35:12 +0000 (03:35 +0200)]
Support omitting log file path on dlog

If a log file path is not given, then lines are printed back to standard
output. This may be useful to add timestamps to lines.

12 years agoAdd dlog manual page
Adrian Perez [Fri, 30 Jul 2010 01:00:35 +0000 (03:00 +0200)]
Add dlog manual page

12 years agoImplement dlog utility
Adrian Perez [Fri, 30 Jul 2010 00:56:16 +0000 (02:56 +0200)]
Implement dlog utility

12 years agoFix file headers, rename dmon-util.* -> util.*
Adrian Perez [Fri, 30 Jul 2010 00:33:38 +0000 (02:33 +0200)]
Fix file headers, rename dmon-util.* -> util.*

12 years agoAdd dsyslog manual page
Adrian Perez [Fri, 30 Jul 2010 00:29:25 +0000 (02:29 +0200)]
Add dsyslog manual page

12 years agoRewrite code in terms of iolib.[hc]
Adrian Perez [Fri, 30 Jul 2010 00:15:00 +0000 (02:15 +0200)]
Rewrite code in terms of iolib.[hc]

This makes utilities not use the heavyweight stdio buffers from libc,
but a lighter version.

12 years agoAdd support for @e/@E formatters in iolib.[hc]
Adrian Perez [Fri, 30 Jul 2010 00:14:41 +0000 (02:14 +0200)]
Add support for @e/@E formatters in iolib.[hc]

12 years agoAdd vformat() function to iolib.[hc]
Adrian Perez [Fri, 30 Jul 2010 00:14:10 +0000 (02:14 +0200)]
Add vformat() function to iolib.[hc]

12 years agoProper indentation and modelines
Adrian Perez [Thu, 29 Jul 2010 23:57:14 +0000 (01:57 +0200)]
Proper indentation and modelines

12 years agoClose standard output after initialization
Adrian Perez [Thu, 29 Jul 2010 23:53:18 +0000 (01:53 +0200)]
Close standard output after initialization

The standard output stream can be safely closed, because after
initialization (which could print messages to stdout when -h/-? are
passed) all possible messages are error messages, and those go to
standard error instead.

12 years agoImplementation of dsyslog
Adrian Perez [Thu, 29 Jul 2010 23:42:02 +0000 (01:42 +0200)]
Implementation of dsyslog

"dsyslog" will read lines from standard input, and then send each line to
the system logger.

12 years agoExpand tabs in indentation
Adrian Perez [Thu, 29 Jul 2010 22:32:55 +0000 (00:32 +0200)]
Expand tabs in indentation

12 years agoInitial import
Adrian Perez [Thu, 29 Jul 2010 22:28:21 +0000 (00:28 +0200)]
Initial import