Davin McCall [Sat, 6 Jan 2018 21:43:40 +0000 (21:43 +0000)]
Add "tests" generated binary to .gitignore
Davin McCall [Sat, 6 Jan 2018 19:03:58 +0000 (19:03 +0000)]
Use _Pragma to turn off invalid-offsetof warnings at appropriate places.
This means that we no longer need to build with -Wno-invalid-offsetof.
Davin McCall [Sat, 6 Jan 2018 15:20:03 +0000 (15:20 +0000)]
Add some missing includes, necessary on some platforms.
Davin McCall [Fri, 5 Jan 2018 20:09:28 +0000 (20:09 +0000)]
Allow for interrupting process startup (by sending SIGINT).
Davin McCall [Fri, 5 Jan 2018 19:33:47 +0000 (19:33 +0000)]
Refactoring: Move fields from service_record to base_process_service.
Davin McCall [Thu, 4 Jan 2018 11:07:37 +0000 (11:07 +0000)]
service_record: encapsulation: make some members private, add accessors.
Davin McCall [Tue, 19 Dec 2017 10:01:07 +0000 (10:01 +0000)]
Build and run tests with sanitizers enabled.
Davin McCall [Fri, 5 Jan 2018 07:17:58 +0000 (07:17 +0000)]
Merge pull request #1 from mskarbek/tests_fix
Fixed tests after start_ps_process and all_deps_stopped rename.
Marcin Skarbek [Fri, 5 Jan 2018 01:16:32 +0000 (02:16 +0100)]
Fixed tests
Fixed tests after start_ps_process and all_deps_stopped rename
Davin McCall [Sun, 31 Dec 2017 20:19:21 +0000 (20:19 +0000)]
Renamed 'start_ps_process' function to 'bring_up'.
Also some minor reorganising, improve comments etc.
Davin McCall [Sun, 31 Dec 2017 20:10:22 +0000 (20:10 +0000)]
Rename 'all_deps_stopped' function to 'bring_down'.
The former name doesn't imply the action to be taken.
Davin McCall [Sun, 31 Dec 2017 20:02:41 +0000 (20:02 +0000)]
Make do_start/do_stop protected instead of public.
Davin McCall [Sun, 31 Dec 2017 16:29:31 +0000 (16:29 +0000)]
Handle fork+exec failure in a separate virtual method.
This cleans up the code and removes a lot of conditional handling for
the different service types.
Davin McCall [Sun, 31 Dec 2017 15:24:56 +0000 (15:24 +0000)]
Typo fix.
Davin McCall [Thu, 28 Dec 2017 00:07:32 +0000 (00:07 +0000)]
Fix potential issue stopping process services.
Process services undergoing smooth recovery count as "STARTED" but have
a pid of -1, or a valid pid but with a process launch underway (waiting
for exec status). If all dependencies stopped at the wrong time, the
behaviour was to treat the service as stopped, but the smooth recovery
was still kicking on and could cause an issue if it "succeeded" after
the service was supposedly terminated.
To resolve this, don't send a kill signal to a process during smooth
recovery (i.e. if waiting_for_execstat is true) and send it once
recovery has completed instead.
Davin McCall [Wed, 27 Dec 2017 00:58:35 +0000 (00:58 +0000)]
Various minor cleanups.
Davin McCall [Tue, 26 Dec 2017 14:18:52 +0000 (14:18 +0000)]
Build: use EXTRA_LIBS when building "shutdown".
Davin McCall [Tue, 26 Dec 2017 14:18:26 +0000 (14:18 +0000)]
bgproc_service: remove redundant initialisation from subclass.
Davin McCall [Sun, 24 Dec 2017 14:03:42 +0000 (14:03 +0000)]
Update comparison on similar systems.
Davin McCall [Sun, 24 Dec 2017 11:36:26 +0000 (11:36 +0000)]
Update Dasynq to 1.0.3.
Davin McCall [Fri, 22 Dec 2017 20:10:41 +0000 (20:10 +0000)]
Update Dasynq to 1.0.2.
Davin McCall [Mon, 18 Dec 2017 09:28:56 +0000 (09:28 +0000)]
Upgrade bundled Dasynq to 1.0.1.
Davin McCall [Mon, 11 Dec 2017 18:45:12 +0000 (05:45 +1100)]
Incorporate upstream changes from Dasynq.
This updates bundled Dasynq to 1.0 (plus minor changes since).
Davin McCall [Tue, 3 Oct 2017 21:33:42 +0000 (22:33 +0100)]
Add some tests for milestone dependencies.
Davin McCall [Mon, 2 Oct 2017 19:38:39 +0000 (20:38 +0100)]
Define and use a macro to run a named test.
Davin McCall [Mon, 2 Oct 2017 19:20:51 +0000 (20:20 +0100)]
Add "depends-ms" dependency option for milestone dependencies.
Davin McCall [Sun, 1 Oct 2017 23:49:35 +0000 (00:49 +0100)]
Correct use of SOFT vs WAITS_FOR dependency type in various places.
Also fix implementation of WAITS_FOR. SOFT presently behaves the same as
WAITS_FOR (but cannot presently be specified as a dependency type in a
service description).
Davin McCall [Fri, 29 Sep 2017 20:10:31 +0000 (21:10 +0100)]
Simplify dependency checking logic.
Davin McCall [Fri, 29 Sep 2017 19:26:05 +0000 (20:26 +0100)]
Add service set destructor.
Destructor deletes all services in the service set. This fixes a memory
leak currently present in the tests.
Davin McCall [Wed, 27 Sep 2017 15:44:10 +0000 (16:44 +0100)]
Re-work dependency specification for service_record constructors.
Dependencies of different types are now given together in a single list,
wth each dependency tagged by its type, rather than as two lists (one
for regular and one for soft dependencies). This opens up the
possibility of supporting additional dependency types.
Davin McCall [Thu, 7 Sep 2017 19:05:39 +0000 (20:05 +0100)]
Improve a test (and make it pass).
When a service is unpinned from pinned start, it needs to check
force_stop and stop if set.
Davin McCall [Tue, 5 Sep 2017 21:51:29 +0000 (22:51 +0100)]
Fix test 6, add a new test (test 7).
Davin McCall [Tue, 5 Sep 2017 08:14:39 +0000 (09:14 +0100)]
Keep all dependencies (soft and regular) in a single list.
We had separate lists for regular dependencies, dependents, and soft
dependencies and dependents. Combining the two dependency types
simplifies code in several places and allows for adding new dependency
types much more easily.
Davin McCall [Fri, 7 Jul 2017 18:53:13 +0000 (19:53 +0100)]
ss_read: silence signed vs unsigned comparison warning.
Davin McCall [Fri, 7 Jul 2017 18:52:39 +0000 (19:52 +0100)]
tests: add another.
Davin McCall [Fri, 7 Jul 2017 17:13:40 +0000 (18:13 +0100)]
service: fix recently introduced double-start bug.
Davin McCall [Thu, 6 Jul 2017 16:22:58 +0000 (17:22 +0100)]
Tests: add another test.
Davin McCall [Thu, 6 Jul 2017 16:11:21 +0000 (17:11 +0100)]
Fix "make check" on OS X / BSD.
Davin McCall [Thu, 6 Jul 2017 16:09:02 +0000 (17:09 +0100)]
tests: correct get_state call (after rename from getState).
Davin McCall [Wed, 5 Jul 2017 20:04:36 +0000 (21:04 +0100)]
Dasynq: merge changes from upstream.
Davin McCall [Tue, 4 Jul 2017 18:36:13 +0000 (19:36 +0100)]
TODO list: a couple of items done.
Davin McCall [Tue, 4 Jul 2017 18:34:42 +0000 (19:34 +0100)]
More camelCase to under_score renaming.
Davin McCall [Tue, 4 Jul 2017 18:07:37 +0000 (19:07 +0100)]
Consolidate linux-specific code.
Davin McCall [Tue, 4 Jul 2017 08:37:21 +0000 (09:37 +0100)]
Various renaming of camelCase to underscored_name for consistency.
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).
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.
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.
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.
Davin McCall [Tue, 27 Jun 2017 23:10:44 +0000 (00:10 +0100)]
TODO: update
Davin McCall [Tue, 27 Jun 2017 18:30:45 +0000 (19:30 +0100)]
Fix spacing / remove hard tabs.
Davin McCall [Tue, 27 Jun 2017 16:29:11 +0000 (17:29 +0100)]
service descriptions: Implement the stop-timeout setting.
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.
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).
Davin McCall [Tue, 27 Jun 2017 08:36:01 +0000 (09:36 +0100)]
service: add safety check before unlinking old socket path.
Davin McCall [Mon, 26 Jun 2017 18:26:46 +0000 (19:26 +0100)]
service: improve robustness of read_pid_file().
Cleans up some TODOs.
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.
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).
Davin McCall [Mon, 26 Jun 2017 09:15:25 +0000 (10:15 +0100)]
process service: more fixes to child watch reservation.
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.
Davin McCall [Mon, 26 Jun 2017 08:32:40 +0000 (09:32 +0100)]
Improve code documentation.
Davin McCall [Sun, 25 Jun 2017 16:51:42 +0000 (17:51 +0100)]
Fix child watch reservation.
Davin McCall [Fri, 23 Jun 2017 09:29:17 +0000 (10:29 +0100)]
Fix minor typos
Davin McCall [Fri, 23 Jun 2017 09:00:26 +0000 (10:00 +0100)]
Correct restart delay check (<= instead of <).
Davin McCall [Fri, 23 Jun 2017 08:56:53 +0000 (09:56 +0100)]
Incorporate changes from Dasynq upstream.
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.
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).
Davin McCall [Mon, 19 Jun 2017 09:02:39 +0000 (10:02 +0100)]
dinitctl: clean up a TODO.
Davin McCall [Mon, 19 Jun 2017 08:57:02 +0000 (09:57 +0100)]
Remove unneeded function parameter.
Also rename: processQueues to process_queues.
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.)
Davin McCall [Sat, 17 Jun 2017 23:54:41 +0000 (00:54 +0100)]
If a service stops and won't restart, release explicit activation.
Davin McCall [Sat, 17 Jun 2017 23:11:00 +0000 (00:11 +0100)]
slist: fix condition for detecting queued item.
Davin McCall [Sat, 17 Jun 2017 10:26:59 +0000 (11:26 +0100)]
Build: fix dependencies of tests executable.
Davin McCall [Fri, 16 Jun 2017 20:13:36 +0000 (21:13 +0100)]
Allow "make check" to run tests.
Davin McCall [Fri, 16 Jun 2017 20:13:02 +0000 (21:13 +0100)]
Fix missing #include
Davin McCall [Fri, 16 Jun 2017 19:48:35 +0000 (20:48 +0100)]
Beginnings of automated test suite.
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.
Davin McCall [Fri, 16 Jun 2017 17:31:24 +0000 (18:31 +0100)]
Refactoring: don't pass list via pointer.
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.
Davin McCall [Fri, 16 Jun 2017 09:10:48 +0000 (10:10 +0100)]
Rename ServiceState to service_state_t.
Davin McCall [Fri, 16 Jun 2017 08:57:27 +0000 (09:57 +0100)]
Rename ServiceIoWatcher to exec_status_pipe_watcher.
Davin McCall [Thu, 15 Jun 2017 23:21:53 +0000 (00:21 +0100)]
Fix dinitctl man page for conversion to html.
Davin McCall [Thu, 15 Jun 2017 18:41:27 +0000 (19:41 +0100)]
Remove unwanted comment tag
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).
Davin McCall [Thu, 15 Jun 2017 14:45:09 +0000 (15:45 +0100)]
Signal a service process via its process group rather than individually.
Davin McCall [Thu, 15 Jun 2017 11:22:17 +0000 (12:22 +0100)]
Rename various classes/functions for consistency.
ServiceSet to service_set, etc.
Davin McCall [Thu, 15 Jun 2017 08:37:38 +0000 (09:37 +0100)]
Rename ServiceRecord to service_record for consistency
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.
Davin McCall [Tue, 13 Jun 2017 00:01:28 +0000 (01:01 +0100)]
Use time arithmetic functions from Dasynq (time_val).
Davin McCall [Mon, 12 Jun 2017 23:51:47 +0000 (00:51 +0100)]
Incorporate changes from Dasynq upstream.
Davin McCall [Mon, 12 Jun 2017 22:53:39 +0000 (23:53 +0100)]
Fix issues with restart counting and start failure handling.
Davin McCall [Mon, 12 Jun 2017 21:25:57 +0000 (22:25 +0100)]
Fix console queue behavior (was broken by recent changes).
Davin McCall [Mon, 12 Jun 2017 20:45:00 +0000 (21:45 +0100)]
On interrupted start, unlink from console wait queue.
Davin McCall [Mon, 12 Jun 2017 18:03:39 +0000 (19:03 +0100)]
Minor improvements to dinitctl manpage.
Davin McCall [Mon, 12 Jun 2017 18:00:04 +0000 (19:00 +0100)]
Fix potential issue of double-queueing for console breakage.
Davin McCall [Mon, 12 Jun 2017 17:50:25 +0000 (18:50 +0100)]
Convert various queues to instantiations of generic queue type
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.
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.
Davin McCall [Fri, 9 Jun 2017 16:02:43 +0000 (17:02 +0100)]
Add man page for dinitctl.
Davin McCall [Thu, 8 Jun 2017 22:24:54 +0000 (23:24 +0100)]
Update TODO again...
Davin McCall [Thu, 8 Jun 2017 22:22:55 +0000 (23:22 +0100)]
Update TODO.