oweals/dinit.git
6 years agoVarious renaming of camelCase to underscored_name for consistency.
Davin McCall [Tue, 4 Jul 2017 08:37:21 +0000 (09:37 +0100)]
Various renaming of camelCase to underscored_name for consistency.

6 years ago(Linux) set dinit as child subreaper.
Davin McCall [Mon, 3 Jul 2017 00:12:33 +0000 (01:12 +0100)]
(Linux) set dinit as child subreaper.

This allows catching/watching double-forking processes even if we
are not PID 1. Double-fork orphans will be reparented to the
subreaper (i.e. Dinit) rather than PID 1 (init).

6 years agoUse getpgid to determine process group of service process.
Davin McCall [Mon, 3 Jul 2017 00:10:28 +0000 (01:10 +0100)]
Use getpgid to determine process group of service process.

Using pid (i.e. 'kill(-pid, signo)') doesn't work if the process has
double-forked but not set a new process group for the child, and
anyway it's not clear if POSIX actually guarantees that process group
IDs will match process IDs.

6 years agosmooth recovery: wait for dependencies to start before relaunch.
Davin McCall [Thu, 29 Jun 2017 17:55:41 +0000 (18:55 +0100)]
smooth recovery: wait for dependencies to start before relaunch.

If pinned started, dependencies may be stopped; the smooth recovery
process should wait for dependencies to start before trying to re-launch
the service process.

6 years agobgprocess: eliminate doing_recovery field.
Davin McCall [Thu, 29 Jun 2017 10:12:56 +0000 (11:12 +0100)]
bgprocess: eliminate doing_recovery field.

We can use the existing 'restarting' instead after some minor changes.

6 years agoTODO: update
Davin McCall [Tue, 27 Jun 2017 23:10:44 +0000 (00:10 +0100)]
TODO: update

6 years agoFix spacing / remove hard tabs.
Davin McCall [Tue, 27 Jun 2017 18:30:45 +0000 (19:30 +0100)]
Fix spacing / remove hard tabs.

6 years agoservice descriptions: Implement the stop-timeout setting.
Davin McCall [Tue, 27 Jun 2017 16:29:11 +0000 (17:29 +0100)]
service descriptions: Implement the stop-timeout setting.

6 years agoservice: implement stop timeout / hard kill.
Davin McCall [Tue, 27 Jun 2017 16:05:30 +0000 (17:05 +0100)]
service: implement stop timeout / hard kill.

If a service fails to stop in its alloted time, it will be killed with
SIGKILL. The timeout is currently hardcoded to 10 seconds.

6 years agoservice: check error from kill when checking ability to track child.
Davin McCall [Tue, 27 Jun 2017 08:54:31 +0000 (09:54 +0100)]
service: check error from kill when checking ability to track child.

We check whether the process exists using kill. We were treating any
error return as meaning the process ID was invalid, but in fact we may
simply not have permission to signal the process (if we are not being
run as root and the service process is suid).

6 years agoservice: add safety check before unlinking old socket path.
Davin McCall [Tue, 27 Jun 2017 08:36:01 +0000 (09:36 +0100)]
service: add safety check before unlinking old socket path.

6 years agoservice: improve robustness of read_pid_file().
Davin McCall [Mon, 26 Jun 2017 18:26:46 +0000 (19:26 +0100)]
service: improve robustness of read_pid_file().

Cleans up some TODOs.

6 years agoservice: use recorded state to check whether we can track child process
Davin McCall [Mon, 26 Jun 2017 17:58:03 +0000 (18:58 +0100)]
service: use recorded state to check whether we can track child process

We have a flag which records whether we are tracking the child process.
A BGPROCESS service can't always track the child, so it stops once the
dependencies have stopped without waiting for the process. Previously we
did a manual check rather than using the existing flag to see whether
the process could be tracked before immediately stopping.

6 years agoMakefile: fix warnings on initial build due to missing *.d files.
Davin McCall [Mon, 26 Jun 2017 09:21:49 +0000 (10:21 +0100)]
Makefile: fix warnings on initial build due to missing *.d files.

These are the auto-generated dependency information files, which do not
exist on initial build (or after clean).

6 years agoprocess service: more fixes to child watch reservation.
Davin McCall [Mon, 26 Jun 2017 09:15:25 +0000 (10:15 +0100)]
process service: more fixes to child watch reservation.

6 years agoVarious renaming (from CamelCase to underscore_separated).
Davin McCall [Mon, 26 Jun 2017 08:42:32 +0000 (09:42 +0100)]
Various renaming (from CamelCase to underscore_separated).

For consistency with most of the rest of the code base.

6 years agoImprove code documentation.
Davin McCall [Mon, 26 Jun 2017 08:32:40 +0000 (09:32 +0100)]
Improve code documentation.

6 years agoFix child watch reservation.
Davin McCall [Sun, 25 Jun 2017 16:51:42 +0000 (17:51 +0100)]
Fix child watch reservation.

6 years agoFix minor typos
Davin McCall [Fri, 23 Jun 2017 09:29:17 +0000 (10:29 +0100)]
Fix minor typos

6 years agoCorrect restart delay check (<= instead of <).
Davin McCall [Fri, 23 Jun 2017 09:00:26 +0000 (10:00 +0100)]
Correct restart delay check (<= instead of <).

6 years agoIncorporate changes from Dasynq upstream.
Davin McCall [Fri, 23 Jun 2017 08:56:53 +0000 (09:56 +0100)]
Incorporate changes from Dasynq upstream.

6 years agoImprove handling of pid-file reading.
Davin McCall [Tue, 20 Jun 2017 18:06:47 +0000 (19:06 +0100)]
Improve handling of pid-file reading.

This is a step towards fixing a resource-allocation issue. Currently
when a bgprocess is restarting we add a "child" listener, but we can't
be sure that we will receive notification because the process might not
be a direct child. Also we should add a listener in an allocation-free
manner, but this might need an update to Dasynq.

6 years agoload_service: remove another TODO.
Davin McCall [Mon, 19 Jun 2017 09:06:47 +0000 (10:06 +0100)]
load_service: remove another TODO.

It's not worth writing a number parser just so we can error out if the
user happens to specify a value of -0 (only >= 0 is allowed).

6 years agodinitctl: clean up a TODO.
Davin McCall [Mon, 19 Jun 2017 09:02:39 +0000 (10:02 +0100)]
dinitctl: clean up a TODO.

6 years agoRemove unneeded function parameter.
Davin McCall [Mon, 19 Jun 2017 08:57:02 +0000 (09:57 +0100)]
Remove unneeded function parameter.

Also rename: processQueues to process_queues.

6 years agoClean up some TODOs.
Davin McCall [Mon, 19 Jun 2017 08:46:42 +0000 (09:46 +0100)]
Clean up some TODOs.

(In both cases, these were on consideration not real problems.)

6 years agoIf a service stops and won't restart, release explicit activation.
Davin McCall [Sat, 17 Jun 2017 23:54:41 +0000 (00:54 +0100)]
If a service stops and won't restart, release explicit activation.

6 years agoslist: fix condition for detecting queued item.
Davin McCall [Sat, 17 Jun 2017 23:11:00 +0000 (00:11 +0100)]
slist: fix condition for detecting queued item.

6 years agoBuild: fix dependencies of tests executable.
Davin McCall [Sat, 17 Jun 2017 10:26:59 +0000 (11:26 +0100)]
Build: fix dependencies of tests executable.

6 years agoAllow "make check" to run tests.
Davin McCall [Fri, 16 Jun 2017 20:13:36 +0000 (21:13 +0100)]
Allow "make check" to run tests.

6 years agoFix missing #include
Davin McCall [Fri, 16 Jun 2017 20:13:02 +0000 (21:13 +0100)]
Fix missing #include

6 years agoBeginnings of automated test suite.
Davin McCall [Fri, 16 Jun 2017 19:48:35 +0000 (20:48 +0100)]
Beginnings of automated test suite.

6 years agoBuild: remove manual *.h dependencies.
Davin McCall [Fri, 16 Jun 2017 17:32:31 +0000 (18:32 +0100)]
Build: remove manual *.h dependencies.

The auto-dependency generation should handle all include files.

6 years agoRefactoring: don't pass list via pointer.
Davin McCall [Fri, 16 Jun 2017 17:31:24 +0000 (18:31 +0100)]
Refactoring: don't pass list via pointer.

6 years agoRefactoring: split loading service from directory into seperate class
Davin McCall [Fri, 16 Jun 2017 16:11:41 +0000 (17:11 +0100)]
Refactoring: split loading service from directory into seperate class

dirload_service_set, a new class, extends from service_set and overloads
service load functionality. service_set's standard load_service function
now simply errors out.

6 years agoRename ServiceState to service_state_t.
Davin McCall [Fri, 16 Jun 2017 09:10:48 +0000 (10:10 +0100)]
Rename ServiceState to service_state_t.

6 years agoRename ServiceIoWatcher to exec_status_pipe_watcher.
Davin McCall [Fri, 16 Jun 2017 08:57:27 +0000 (09:57 +0100)]
Rename ServiceIoWatcher to exec_status_pipe_watcher.

6 years agoFix dinitctl man page for conversion to html.
Davin McCall [Thu, 15 Jun 2017 23:21:53 +0000 (00:21 +0100)]
Fix dinitctl man page for conversion to html.

6 years agoRemove unwanted comment tag
Davin McCall [Thu, 15 Jun 2017 18:41:27 +0000 (19:41 +0100)]
Remove unwanted comment tag

6 years agoIncrease priority of service child status watchers.
Davin McCall [Thu, 15 Jun 2017 18:37:04 +0000 (19:37 +0100)]
Increase priority of service child status watchers.

We want to make sure that if we send a signal to a service process, we
haven't already reaped that process (since in that case, in theory, the
process ID may have been re-used and we will end up signalling the wrong
process).

6 years agoSignal a service process via its process group rather than individually.
Davin McCall [Thu, 15 Jun 2017 14:45:09 +0000 (15:45 +0100)]
Signal a service process via its process group rather than individually.

6 years agoRename various classes/functions for consistency.
Davin McCall [Thu, 15 Jun 2017 11:22:17 +0000 (12:22 +0100)]
Rename various classes/functions for consistency.

ServiceSet to service_set, etc.

6 years agoRename ServiceRecord to service_record for consistency
Davin McCall [Thu, 15 Jun 2017 08:37:38 +0000 (09:37 +0100)]
Rename ServiceRecord to service_record for consistency

6 years agoMan page updates.
Davin McCall [Wed, 14 Jun 2017 17:07:03 +0000 (18:07 +0100)]
Man page updates.

Man pages should be section 8, not section 1. Add "list" command info to
dinitctl manpage.

6 years agoUse time arithmetic functions from Dasynq (time_val).
Davin McCall [Tue, 13 Jun 2017 00:01:28 +0000 (01:01 +0100)]
Use time arithmetic functions from Dasynq (time_val).

6 years agoIncorporate changes from Dasynq upstream.
Davin McCall [Mon, 12 Jun 2017 23:51:47 +0000 (00:51 +0100)]
Incorporate changes from Dasynq upstream.

6 years agoFix issues with restart counting and start failure handling.
Davin McCall [Mon, 12 Jun 2017 22:53:39 +0000 (23:53 +0100)]
Fix issues with restart counting and start failure handling.

6 years agoFix console queue behavior (was broken by recent changes).
Davin McCall [Mon, 12 Jun 2017 21:25:57 +0000 (22:25 +0100)]
Fix console queue behavior (was broken by recent changes).

6 years agoOn interrupted start, unlink from console wait queue.
Davin McCall [Mon, 12 Jun 2017 20:45:00 +0000 (21:45 +0100)]
On interrupted start, unlink from console wait queue.

6 years agoMinor improvements to dinitctl manpage.
Davin McCall [Mon, 12 Jun 2017 18:03:39 +0000 (19:03 +0100)]
Minor improvements to dinitctl manpage.

6 years agoFix potential issue of double-queueing for console breakage.
Davin McCall [Mon, 12 Jun 2017 18:00:04 +0000 (19:00 +0100)]
Fix potential issue of double-queueing for console breakage.

6 years agoConvert various queues to instantiations of generic queue type
Davin McCall [Mon, 12 Jun 2017 17:50:25 +0000 (18:50 +0100)]
Convert various queues to instantiations of generic queue type

6 years agoService logic simplification/cleanup.
Davin McCall [Sat, 10 Jun 2017 22:22:56 +0000 (23:22 +0100)]
Service logic simplification/cleanup.

Cleanly separate initial state propagation from transition actions.

6 years agoservice: only force stop dependents if necessary.
Davin McCall [Fri, 9 Jun 2017 16:19:11 +0000 (17:19 +0100)]
service: only force stop dependents if necessary.

Only force-stop dependent services if this service is force-stopped.

6 years agoAdd man page for dinitctl.
Davin McCall [Fri, 9 Jun 2017 16:02:43 +0000 (17:02 +0100)]
Add man page for dinitctl.

6 years agoUpdate TODO again...
Davin McCall [Thu, 8 Jun 2017 22:24:54 +0000 (23:24 +0100)]
Update TODO again...

6 years agoUpdate TODO.
Davin McCall [Thu, 8 Jun 2017 22:22:55 +0000 (23:22 +0100)]
Update TODO.

6 years agoRemove no-longer-relevant comment.
Davin McCall [Thu, 8 Jun 2017 22:21:54 +0000 (23:21 +0100)]
Remove no-longer-relevant comment.

6 years agoEnable SIGQUIT in child processes.
Davin McCall [Thu, 8 Jun 2017 20:56:32 +0000 (21:56 +0100)]
Enable SIGQUIT in child processes.

6 years agoInstall Dinit manpage on "make install".
Davin McCall [Thu, 8 Jun 2017 20:16:21 +0000 (21:16 +0100)]
Install Dinit manpage on "make install".

6 years agoSignal handling improvements.
Davin McCall [Thu, 8 Jun 2017 20:06:35 +0000 (21:06 +0100)]
Signal handling improvements.

Don't handle SIGQUIT in user mode. Also, when receiving SIGINT in user
mode, terminate via SIGINT so that the correct exit status is returned.

6 years agoPerform sync() if we fail to exec shutdown.
Davin McCall [Thu, 8 Jun 2017 18:02:51 +0000 (19:02 +0100)]
Perform sync() if we fail to exec shutdown.

6 years agoWait for user acknowledgement before rebooting on boot failure.
Davin McCall [Thu, 8 Jun 2017 17:32:20 +0000 (18:32 +0100)]
Wait for user acknowledgement before rebooting on boot failure.

If we can't load the boot service, rebooting immediately will likely
lead to a boot loop. Instead, prompt the user to acknowledge issue.

6 years agoMinor error-handling cleanups.
Davin McCall [Thu, 8 Jun 2017 09:30:22 +0000 (10:30 +0100)]
Minor error-handling cleanups.

6 years agoInitial manpage for dinit.
Davin McCall [Thu, 8 Jun 2017 08:11:05 +0000 (09:11 +0100)]
Initial manpage for dinit.

6 years agoDocument restart-delay and logfile settings.
Davin McCall [Thu, 8 Jun 2017 08:10:17 +0000 (09:10 +0100)]
Document restart-delay and logfile settings.

6 years agoHandle different termination signals differently (fix bug).
Davin McCall [Thu, 8 Jun 2017 08:09:50 +0000 (09:09 +0100)]
Handle different termination signals differently (fix bug).

6 years agoAllow service start to be interrupted when waiting for restart timer.
Davin McCall [Tue, 6 Jun 2017 16:16:39 +0000 (17:16 +0100)]
Allow service start to be interrupted when waiting for restart timer.

6 years agoMake service restart delay configurable (restart-delay servie setting).
Davin McCall [Tue, 6 Jun 2017 15:54:13 +0000 (16:54 +0100)]
Make service restart delay configurable (restart-delay servie setting).

6 years agoAdd restart-limit-count service setting.
Davin McCall [Tue, 6 Jun 2017 08:07:01 +0000 (09:07 +0100)]
Add restart-limit-count service setting.

Specifies the maximum number of automatic restarts allowed within the
restart limit interval. Can be set to 0 to disable restart limiting.

6 years agoQuash build warning.
Davin McCall [Mon, 5 Jun 2017 23:00:22 +0000 (00:00 +0100)]
Quash build warning.

6 years agoUpdate BUILD instructions.
Davin McCall [Mon, 5 Jun 2017 22:55:00 +0000 (23:55 +0100)]
Update BUILD instructions.

6 years agoMake restart check interval configurable.
Davin McCall [Mon, 5 Jun 2017 22:06:21 +0000 (23:06 +0100)]
Make restart check interval configurable.

6 years agoLimit number of restarts within an interval
Davin McCall [Mon, 5 Jun 2017 09:26:23 +0000 (10:26 +0100)]
Limit number of restarts within an interval

6 years agoBuild: Use CXXPOPTS when generating dependency files
Davin McCall [Mon, 5 Jun 2017 09:25:43 +0000 (10:25 +0100)]
Build: Use CXXPOPTS when generating dependency files

6 years agoFix: grant console correctly
Davin McCall [Sat, 3 Jun 2017 09:28:58 +0000 (10:28 +0100)]
Fix: grant console correctly

Services marked "starts-on-console" need to be given console access.
Services that restart via "smooth recovery" need to be given console
access if they run-on-console.

6 years agoUpdate gitignore file
Davin McCall [Sat, 3 Jun 2017 08:44:35 +0000 (09:44 +0100)]
Update gitignore file

6 years agoBuild: autogenerate dependency files (*.d)
Davin McCall [Sat, 3 Jun 2017 08:43:05 +0000 (09:43 +0100)]
Build: autogenerate dependency files (*.d)

6 years agoSeparate "runs-on-console" into runs-on- and starts-on- options.
Davin McCall [Fri, 2 Jun 2017 18:39:07 +0000 (19:39 +0100)]
Separate "runs-on-console" into runs-on- and starts-on- options.

6 years agoUse restart timer also for non-smooth-recovery restarts.
Davin McCall [Fri, 2 Jun 2017 18:13:46 +0000 (19:13 +0100)]
Use restart timer also for non-smooth-recovery restarts.

6 years agoCorrect calculation of restart timeout, and up timeout to 200ms.
Davin McCall [Fri, 2 Jun 2017 17:49:13 +0000 (18:49 +0100)]
Correct calculation of restart timeout, and up timeout to 200ms.

6 years agoMinor refactoring / code documentation.
Davin McCall [Thu, 1 Jun 2017 22:02:15 +0000 (23:02 +0100)]
Minor refactoring / code documentation.

6 years agoAdd a restart timer to limit restart rate.
Davin McCall [Thu, 1 Jun 2017 19:14:05 +0000 (20:14 +0100)]
Add a restart timer to limit restart rate.

So far, applied only to "smooth recovery" restarts.

6 years agoREADME: improve wording in one paragraph.
Davin McCall [Thu, 1 Jun 2017 10:11:17 +0000 (11:11 +0100)]
README: improve wording in one paragraph.

6 years agoFix callback method name per Dasynq changes
Davin McCall [Thu, 1 Jun 2017 08:28:08 +0000 (09:28 +0100)]
Fix callback method name per Dasynq changes

6 years agoIncorporate Dasynq changes
Davin McCall [Thu, 1 Jun 2017 07:52:22 +0000 (08:52 +0100)]
Incorporate Dasynq changes

6 years agoClean up one TODO
Davin McCall [Tue, 30 May 2017 10:19:45 +0000 (11:19 +0100)]
Clean up one TODO

6 years agoSimplify allDepStarted logic.
Davin McCall [Tue, 30 May 2017 10:10:23 +0000 (11:10 +0100)]
Simplify allDepStarted logic.

Change default action of start_ps_process to call started(). This is
overriden in base_process_service to launch the process.

6 years agoservice record: move read_pid_file into bgproc_service
Davin McCall [Tue, 30 May 2017 09:29:31 +0000 (10:29 +0100)]
service record: move read_pid_file into bgproc_service

6 years agoservice_record: declare handle_exit_status as pure virtual.
Davin McCall [Tue, 30 May 2017 09:17:23 +0000 (10:17 +0100)]
service_record: declare handle_exit_status as pure virtual.

6 years agoRefactoring: create base_process_service
Davin McCall [Fri, 26 May 2017 18:20:35 +0000 (19:20 +0100)]
Refactoring: create base_process_service

This serves as a base for the three service types which start processes.

6 years agoAvoid releasing console twice on failure to read pid file.
Davin McCall [Fri, 26 May 2017 17:58:54 +0000 (18:58 +0100)]
Avoid releasing console twice on failure to read pid file.

6 years agoFix various missing std::move's (which was an exception safety issue)
Davin McCall [Fri, 26 May 2017 17:34:19 +0000 (18:34 +0100)]
Fix various missing std::move's (which was an exception safety issue)

6 years agoBreak out scripted service as a separate class
Davin McCall [Fri, 26 May 2017 09:29:13 +0000 (10:29 +0100)]
Break out scripted service as a separate class

6 years agoFix pointer bug in logging.
Davin McCall [Wed, 24 May 2017 08:17:31 +0000 (09:17 +0100)]
Fix pointer bug in logging.

6 years agoRefactoring.
Davin McCall [Tue, 23 May 2017 23:19:34 +0000 (00:19 +0100)]
Refactoring.

Move BGPROCESS and PROCESS service records to separate subclasses of
ServiceRecord.

6 years agoMinor cleanups.
Davin McCall [Tue, 23 May 2017 09:28:21 +0000 (10:28 +0100)]
Minor cleanups.

7 years agoProvide and use fallbacks for POSIX functions extended by linux/BSD.
Davin McCall [Wed, 26 Apr 2017 09:35:29 +0000 (10:35 +0100)]
Provide and use fallbacks for POSIX functions extended by linux/BSD.

accept4 isn't standard; Linux and OpenBSD have extensions to socket and
socketpair which allow opening in nonblocking/close-on-exec modes.
Implement adaptor functions which also work when these extensions aren't
present.

7 years agoIncorporate Dasynq library changes.
Davin McCall [Wed, 26 Apr 2017 09:33:00 +0000 (10:33 +0100)]
Incorporate Dasynq library changes.

7 years agoREADME: add instructions on using dinitctl utility. v0.05
Davin McCall [Thu, 30 Mar 2017 10:26:36 +0000 (11:26 +0100)]
README: add instructions on using dinitctl utility.