Davin McCall [Sat, 10 Feb 2018 15:51:35 +0000 (15:51 +0000)]
control: rework handle allocation.
Davin McCall [Sat, 10 Feb 2018 15:32:51 +0000 (15:32 +0000)]
control conn. allocate_service_handle(): exception safety.
Davin McCall [Sat, 10 Feb 2018 14:42:03 +0000 (14:42 +0000)]
Make sure a process service starts-on-console matches runs-on-console.
Davin McCall [Fri, 9 Feb 2018 22:37:18 +0000 (22:37 +0000)]
Implement a timeout (of 5 seconds) for log to flush on shutdown.
Davin McCall [Fri, 9 Feb 2018 22:04:07 +0000 (22:04 +0000)]
Upgrade bundled Dasynq to 1.1.2.
Davin McCall [Sat, 3 Feb 2018 19:26:56 +0000 (19:26 +0000)]
Up version to 0.08.
Davin McCall [Sat, 3 Feb 2018 19:21:35 +0000 (19:21 +0000)]
Add "shutdown" subcommand to dinitctl.
This provides a handy way to shut down a non-system instance of Dinit,
and wait until shutdown is complete.
Davin McCall [Sat, 3 Feb 2018 19:20:16 +0000 (19:20 +0000)]
Update bundled Dasynq (to 1.1.0).
Davin McCall [Sat, 3 Feb 2018 18:38:48 +0000 (18:38 +0000)]
Fix error in control protocol implementation in dinitctl/shutdown.
Davin McCall [Sat, 3 Feb 2018 17:12:53 +0000 (17:12 +0000)]
Adjust compile/link options.
Linux: build with -fno-plt and LTO.
All: build with -std=c++11 rather than -std=gnu++11.
Davin McCall [Sat, 3 Feb 2018 16:41:23 +0000 (16:41 +0000)]
Add #include's to fix OpenBSD build.
Davin McCall [Sat, 3 Feb 2018 16:27:27 +0000 (16:27 +0000)]
dinitctl: various renaming from camelCase
Davin McCall [Thu, 25 Jan 2018 23:14:17 +0000 (23:14 +0000)]
Process tests: check timer status in various tests.
Make sure that timers have been stopped appropriately after state
transitions.
Davin McCall [Thu, 25 Jan 2018 23:13:35 +0000 (23:13 +0000)]
Stop the stop timer when a service stops.
Davin McCall [Thu, 25 Jan 2018 22:17:02 +0000 (22:17 +0000)]
process service: allow start timeout, but don't arm timer.
Timeout for process services is currently meaningless, although when
startup notification is implemented it will take on meaning. This is a
slightly cleaner fix than just forcing the timeout to 0 in the
constructor (since it can then still be later set to a value that won't
work).
Davin McCall [Wed, 24 Jan 2018 23:39:26 +0000 (23:39 +0000)]
Disable default start timeout for process services.
Davin McCall [Sun, 21 Jan 2018 15:34:40 +0000 (15:34 +0000)]
Rename load_service.cc to load-service.cc for consistency.
Davin McCall [Sun, 21 Jan 2018 14:34:58 +0000 (14:34 +0000)]
Fix processing of "run-as" parameter.
Davin McCall [Sun, 21 Jan 2018 12:56:50 +0000 (12:56 +0000)]
Man pages: split service description format to separate man page.
Davin McCall [Sat, 20 Jan 2018 20:42:11 +0000 (20:42 +0000)]
Support for running services as a different user (run-as=...).
Davin McCall [Fri, 19 Jan 2018 23:41:54 +0000 (23:41 +0000)]
Refactoring / clean up.
Davin McCall [Fri, 19 Jan 2018 20:15:05 +0000 (20:15 +0000)]
Move some #include's around to fix build issue.
Davin McCall [Fri, 19 Jan 2018 18:00:35 +0000 (18:00 +0000)]
Move some data/functions from service_record to base_process_service.
Davin McCall [Fri, 19 Jan 2018 10:15:25 +0000 (10:15 +0000)]
Rename getShutdownType function - eliminate snake case.
Davin McCall [Fri, 19 Jan 2018 10:12:24 +0000 (10:12 +0000)]
Re-work console acquisition/release.
Use variables to track when a service is waiting for the console or has
acquired console, rather than using complex combinations of service
state.
Davin McCall [Thu, 18 Jan 2018 23:24:46 +0000 (23:24 +0000)]
Add test for console release for STARTING to STOPPED transition.
Test for console release when a service goes from STARTING to STOPPED.
Currently fails.
Davin McCall [Thu, 18 Jan 2018 22:09:21 +0000 (22:09 +0000)]
Build: rename EXTRA_LIBS to the more conventional LDFLAGS.
Davin McCall [Thu, 18 Jan 2018 21:53:45 +0000 (21:53 +0000)]
Add example mconfig options for FreeBSD.
Davin McCall [Tue, 16 Jan 2018 22:19:52 +0000 (22:19 +0000)]
Renaming of some snake-case functions missed in prior rename batches.
Davin McCall [Tue, 16 Jan 2018 21:01:58 +0000 (21:01 +0000)]
tests build: use dependencies auto-generated from tested sources.
Davin McCall [Tue, 16 Jan 2018 21:01:03 +0000 (21:01 +0000)]
Minor fixes to tests.
Make sure to initialise all service properties in tests.
Davin McCall [Tue, 16 Jan 2018 20:49:00 +0000 (20:49 +0000)]
Add second smooth recovery test.
Davin McCall [Tue, 16 Jan 2018 20:34:06 +0000 (20:34 +0000)]
Update bundled Dasynq to 1.0.4.
Davin McCall [Tue, 16 Jan 2018 17:59:36 +0000 (17:59 +0000)]
Fix smooth recovery test.
The initial process death should cause the process to be restarted after
the restart delay. The test didn't take the start delay into account.
Davin McCall [Tue, 16 Jan 2018 09:13:33 +0000 (09:13 +0000)]
Add process service stop timeout test.
Davin McCall [Mon, 15 Jan 2018 23:15:52 +0000 (23:15 +0000)]
Add a proc test, and name each test.
Names are better than numbers.
Davin McCall [Mon, 15 Jan 2018 22:38:10 +0000 (22:38 +0000)]
service_record: add boolean issue_stop parameter to release function.
Most calls of release() either did not require do_stop to be called (or
were otherwise handling the stop themselves anyway).
Davin McCall [Mon, 15 Jan 2018 21:52:56 +0000 (21:52 +0000)]
Fix issue with process services restarting after start timeout.
A process which fails to start with a timeout should count as a start
failure. Therefore, remove explicit activation in this case (and thereby
prevent the service from restarting).
Davin McCall [Mon, 15 Jan 2018 21:18:57 +0000 (21:18 +0000)]
baseproc-sys.h: Add explanatory comment.
Davin McCall [Mon, 15 Jan 2018 21:16:26 +0000 (21:16 +0000)]
Add getpgid stub to bp_sys namespace.
This is another function we need to mock/stub for tests.
Davin McCall [Mon, 15 Jan 2018 18:36:38 +0000 (18:36 +0000)]
proctests: complete existing tests and add a 4th (currently fails).
Davin McCall [Mon, 15 Jan 2018 18:17:32 +0000 (18:17 +0000)]
make install: put manpages in correct directory.
Earlier fix forgot to include the mconfig file, meaning that
DESTDIR/MANDIR were not defined unless set on build command line.
Davin McCall [Mon, 15 Jan 2018 18:15:33 +0000 (18:15 +0000)]
tests makefile: auto-generate dependencies (*.d) while building objects.
Davin McCall [Mon, 15 Jan 2018 09:10:10 +0000 (09:10 +0000)]
Implement mock functionality for some system calls in bp_sys.
Davin McCall [Sun, 14 Jan 2018 23:34:21 +0000 (23:34 +0000)]
Stub out system functions for testing (WIP).
This is a more thorough and should be an overall better approach than
stubbing/mocking the base_proc_service class itself.
This commit introduces a baseproc-sys.h header which holds aliases for
the system functions that are used (kill, fcntl, etc). When running
tests the functions will be mocked (currently they are rigged to abort
when called).
Davin McCall [Sun, 14 Jan 2018 12:17:19 +0000 (12:17 +0000)]
Move 'run_child_proc' function into a separate source file.
Davin McCall [Sat, 13 Jan 2018 18:52:22 +0000 (18:52 +0000)]
Move base_process_service timer expiry handling out of friend class.
One less friend class is a good thing. The timer now just calls a single
public 'timer_expiry' function. The latter function can also be used in
tests.
Davin McCall [Sat, 13 Jan 2018 16:58:12 +0000 (16:58 +0000)]
Add some process-service tests.
Davin McCall [Sat, 13 Jan 2018 16:47:57 +0000 (16:47 +0000)]
Use general dinit.h header in baseproc-service.cc.
Davin McCall [Sat, 13 Jan 2018 13:18:44 +0000 (13:18 +0000)]
Makefile: build dependency lists (*.d) during regular build.
No need to build the dependency files as a separate step.
Also, make "make check" no longer build main objects.
Davin McCall [Sat, 13 Jan 2018 12:32:33 +0000 (12:32 +0000)]
Stub out Dasynq functionality for tests.
Later some of this may be turned into proper mock functionality.
Davin McCall [Sat, 13 Jan 2018 12:02:03 +0000 (12:02 +0000)]
Add more missing includes for tests.
Davin McCall [Fri, 12 Jan 2018 21:10:30 +0000 (21:10 +0000)]
Fix makefile typo preventing build of 'shutdown'.
Davin McCall [Fri, 12 Jan 2018 20:21:07 +0000 (20:21 +0000)]
tests: infrastructure for implementing mock headers.
We need to duplicate the header directory entirely in order to be able
to replace header 'xyz.h' (so that 'include "xyz.h"' in other, real,
headers resolves to the mock).
Davin McCall [Fri, 12 Jan 2018 20:15:41 +0000 (20:15 +0000)]
Fix some includes (for testing/general resilience).
Davin McCall [Fri, 12 Jan 2018 16:45:51 +0000 (16:45 +0000)]
Move includes into a separate directory.
Davin McCall [Fri, 12 Jan 2018 16:24:41 +0000 (16:24 +0000)]
Minor cleanup: remove unnecessary aliases.
Davin McCall [Fri, 12 Jan 2018 16:17:25 +0000 (16:17 +0000)]
Pull some commonly occurring declarations into a new header file.
Adds a new header file, dinit.h, which includes declarations for some
types and functions exported from dinit.cc.
Davin McCall [Thu, 11 Jan 2018 22:17:54 +0000 (22:17 +0000)]
Tests: use stubs for various functions.
Davin McCall [Thu, 11 Jan 2018 19:34:37 +0000 (19:34 +0000)]
proc-service.cc: add intro comment.
Davin McCall [Thu, 11 Jan 2018 19:09:25 +0000 (19:09 +0000)]
Refactoring: split out exec_succeeded function.
The status pipe watcher (exec_status_pipe_watcher) had some
service-record-type specific code. Split it out as a virtual function.
Davin McCall [Thu, 11 Jan 2018 18:09:32 +0000 (18:09 +0000)]
Move separate_args function from header to source file.
This avoids potential ODR violations. The function isn't worth making
inline, it's large enough and not on a critical path so just compile it
once.
Davin McCall [Thu, 11 Jan 2018 17:44:01 +0000 (17:44 +0000)]
Fix build of tests.
Davin McCall [Thu, 11 Jan 2018 09:04:54 +0000 (09:04 +0000)]
Split service.cc into multiple files.
service.cc becomes service.cc + proc-service.cc + baseproc-service.cc.
The header service.h becomes service.h + proc-service.h.
This refactoring should make testing easier.
Davin McCall [Wed, 10 Jan 2018 18:22:37 +0000 (18:22 +0000)]
Fix issue with start timeouts not correctly stopping dependents.
Davin McCall [Tue, 9 Jan 2018 17:37:34 +0000 (17:37 +0000)]
Big rename/namespace cleanup.
Davin McCall [Tue, 9 Jan 2018 09:56:04 +0000 (09:56 +0000)]
Minor refactoring/code documentation.
Davin McCall [Mon, 8 Jan 2018 22:00:43 +0000 (22:00 +0000)]
Properly handle scripted service start interrupt.
If we issue an interrupt (SIGINT) to a starting script, but the script
completes normally, we should run the stop script before marking the
service as stopped.
Davin McCall [Mon, 8 Jan 2018 19:56:43 +0000 (19:56 +0000)]
Clean up warning in process_restart_timer.
Initialise the service pointer via the constructor to avoid warning.
Davin McCall [Mon, 8 Jan 2018 19:42:34 +0000 (19:42 +0000)]
Rename service_type (type) to service_type_t.
This is consistent with a number of other service-related types, and as
a bonus makes building with GCC 4.8 possible (it was previously confused
by a "service_type service_type = ..." declaration).
Davin McCall [Mon, 8 Jan 2018 19:26:43 +0000 (19:26 +0000)]
Linux examples: use reasonable start-timeout for filesystem services.
Davin McCall [Mon, 8 Jan 2018 11:05:00 +0000 (11:05 +0000)]
Allow specifying service start timeout in service description.
Default is 60 seconds.
Davin McCall [Mon, 8 Jan 2018 09:11:33 +0000 (09:11 +0000)]
Correctly handle start timeout of 0 (i.e. no timeout).
Davin McCall [Sun, 7 Jan 2018 23:39:55 +0000 (23:39 +0000)]
Implement start timeout for services, default of 60 seconds.
If a service doesn't start within the timeout it is sent SIGINT, and
then SIGKILL after the stop timeout (if there is one).
Davin McCall [Sat, 6 Jan 2018 23:47:13 +0000 (23:47 +0000)]
Sample service defs: enable smooth recovery for ttys.
Also change dependency on ttys from depends-on to depends-ms.
Davin McCall [Sat, 6 Jan 2018 23:46:07 +0000 (23:46 +0000)]
Update version to 0.07.
Davin McCall [Sat, 6 Jan 2018 23:07:31 +0000 (23:07 +0000)]
Install: allow specifying sbin and man directories.
Davin McCall [Sat, 6 Jan 2018 22:56:39 +0000 (22:56 +0000)]
Put man pages in the correct directory (man8 not man1).
Davin McCall [Sat, 6 Jan 2018 22:52:08 +0000 (22:52 +0000)]
Add "start-interruptible" service option.
This option allows a service startup to be interrupted if the service
becomes inactive while starting, by sending it the SIGINT signal. This
is useful for file system checks, which can otherwise delay
reboot/shutdown.
Davin McCall [Sat, 6 Jan 2018 22:23:35 +0000 (22:23 +0000)]
Allow decimal comma separator for times expressed as decimals.
Some locales use a comma to separate a decimal whole from its fractional
part, so allow either a decimal stop or a decimal comma.
Davin McCall [Sat, 6 Jan 2018 22:10:10 +0000 (22:10 +0000)]
Fix minor style inconsistencies.
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.