oweals/dinit.git
6 years agoBump version to 0.1.0. v0.1.0
Davin McCall [Thu, 1 Mar 2018 19:59:20 +0000 (19:59 +0000)]
Bump version to 0.1.0.

6 years agoUpdate COMPARISON with other systems.
Davin McCall [Wed, 28 Feb 2018 16:04:43 +0000 (16:04 +0000)]
Update COMPARISON with other systems.

6 years agotests: build fix for OpenBSD.
Davin McCall [Wed, 28 Feb 2018 15:29:40 +0000 (15:29 +0000)]
tests: build fix for OpenBSD.

6 years agoman page: rework slightly.
Davin McCall [Wed, 28 Feb 2018 15:29:29 +0000 (15:29 +0000)]
man page: rework slightly.

6 years agoman pages: reword description of depends-ms dependency.
Davin McCall [Wed, 28 Feb 2018 12:32:11 +0000 (12:32 +0000)]
man pages: reword description of depends-ms dependency.

6 years agoFix: stop milestone dependency before started.
Davin McCall [Wed, 28 Feb 2018 12:08:37 +0000 (12:08 +0000)]
Fix: stop milestone dependency before started.

Stopping a milestone dependency before its dependent has started must
also stop the dependent (the "milestone" hasn't been reached).

Add a test.

6 years agoSet default log level for main log (not console) to INFO.
Davin McCall [Tue, 27 Feb 2018 17:55:58 +0000 (17:55 +0000)]
Set default log level for main log (not console) to INFO.

6 years agoLog system startup.
Davin McCall [Tue, 27 Feb 2018 17:47:42 +0000 (17:47 +0000)]
Log system startup.

6 years agoLogging: support for supressing output to console per message.
Davin McCall [Tue, 27 Feb 2018 17:27:39 +0000 (17:27 +0000)]
Logging: support for supressing output to console per message.

6 years agoMinor man-page fixes.
Davin McCall [Tue, 27 Feb 2018 14:10:40 +0000 (14:10 +0000)]
Minor man-page fixes.

6 years agologging: refactoring, add comment.
Davin McCall [Tue, 27 Feb 2018 13:16:33 +0000 (13:16 +0000)]
logging: refactoring, add comment.

6 years agoRead environment from file at startup.
Davin McCall [Mon, 26 Feb 2018 22:53:40 +0000 (22:53 +0000)]
Read environment from file at startup.

6 years agoAllow setting working directory for services.
Davin McCall [Fri, 23 Feb 2018 18:40:45 +0000 (18:40 +0000)]
Allow setting working directory for services.

6 years agoClean up a comparison warning.
Davin McCall [Tue, 20 Feb 2018 20:09:44 +0000 (20:09 +0000)]
Clean up a comparison warning.

6 years agoAdd another (passing) test.
Davin McCall [Tue, 20 Feb 2018 19:07:04 +0000 (19:07 +0000)]
Add another (passing) test.

6 years agoAdd another test and a fix to make it pass.
Davin McCall [Tue, 20 Feb 2018 18:59:41 +0000 (18:59 +0000)]
Add another test and a fix to make it pass.

6 years agoMove processing of start pin in do_stop.
Davin McCall [Tue, 20 Feb 2018 11:43:51 +0000 (11:43 +0000)]
Move processing of start pin in do_stop.

The pin should prevent the process from stopping, but not from any other
effects on dependencies. This change makes dependencies of a
start-pinned service potentially go into STOPPING state, if the pinned
service is issued a stop.

6 years agoAdditional comment to better explain two-phase service transition.
Davin McCall [Tue, 20 Feb 2018 10:19:06 +0000 (10:19 +0000)]
Additional comment to better explain two-phase service transition.

6 years agoAdd comment.
Davin McCall [Mon, 19 Feb 2018 10:57:40 +0000 (10:57 +0000)]
Add comment.

6 years agoAdd a new test.
Davin McCall [Mon, 19 Feb 2018 10:39:24 +0000 (10:39 +0000)]
Add a new test.

6 years agoDon't bypass queue cycle in emergency_stop.
Davin McCall [Fri, 16 Feb 2018 10:09:54 +0000 (10:09 +0000)]
Don't bypass queue cycle in emergency_stop.

Rather than calling stopped() directly from emergency_stop(), wait for
the transition cycle.

6 years agoUpdate TODO.
Davin McCall [Thu, 15 Feb 2018 19:04:25 +0000 (19:04 +0000)]
Update TODO.

6 years agoOn interrupting start of scripted service, run stop script.
Davin McCall [Thu, 15 Feb 2018 18:32:19 +0000 (18:32 +0000)]
On interrupting start of scripted service, run stop script.

If a scripted service startup is interrupted via signal, run the stop
script in case cleanup is required.

6 years agoMock tcsetpgrp() and getpgrp() for tests.
Davin McCall [Tue, 13 Feb 2018 18:32:01 +0000 (18:32 +0000)]
Mock tcsetpgrp() and getpgrp() for tests.

6 years agoRefactoring in utilities.
Davin McCall [Tue, 13 Feb 2018 18:14:29 +0000 (18:14 +0000)]
Refactoring in utilities.

6 years agoFix test build failures.
Davin McCall [Mon, 12 Feb 2018 20:46:05 +0000 (20:46 +0000)]
Fix test build failures.

6 years agodinitctl: query protocol version at beginning + refactoring.
Davin McCall [Mon, 12 Feb 2018 20:34:56 +0000 (20:34 +0000)]
dinitctl: query protocol version at beginning + refactoring.

6 years agoFactor out some Dinit client functions tp a new header (dinit-client.h).
Davin McCall [Mon, 5 Feb 2018 10:58:44 +0000 (10:58 +0000)]
Factor out some Dinit client functions tp a new header (dinit-client.h).

6 years agoOn FreeBSD, build without -fno-rtti.
Davin McCall [Sun, 11 Feb 2018 15:02:25 +0000 (15:02 +0000)]
On FreeBSD, build without -fno-rtti.

It seems to stop exception handling from being able to recognise which
exception was thrown.

6 years agoAllow initial services to be specified on command-line on non-Linux OS.
Davin McCall [Sun, 11 Feb 2018 13:05:44 +0000 (13:05 +0000)]
Allow initial services to be specified on command-line on non-Linux OS.

6 years agoMark as a subreaper on FreeBSD (as for Linux).
Davin McCall [Sat, 10 Feb 2018 19:59:51 +0000 (19:59 +0000)]
Mark as a subreaper on FreeBSD (as for Linux).

This means double-forking processes become a child of Dinit rather than
PID 1 (in case they are different).

6 years agoImplement service unloading.
Davin McCall [Sat, 10 Feb 2018 17:22:41 +0000 (17:22 +0000)]
Implement service unloading.

Implements the requisite control protocol parts and the dinitctl
"unload" command.

6 years agobase_process_service: properly clean up in destructor.
Davin McCall [Sat, 10 Feb 2018 16:53:09 +0000 (16:53 +0000)]
base_process_service: properly clean up in destructor.

6 years agoRenaming: camelCase to snake_case.
Davin McCall [Sat, 10 Feb 2018 15:53:35 +0000 (15:53 +0000)]
Renaming: camelCase to snake_case.

6 years agocontrol: rework handle allocation.
Davin McCall [Sat, 10 Feb 2018 15:51:35 +0000 (15:51 +0000)]
control: rework handle allocation.

6 years agocontrol conn. allocate_service_handle(): exception safety.
Davin McCall [Sat, 10 Feb 2018 15:32:51 +0000 (15:32 +0000)]
control conn. allocate_service_handle(): exception safety.

6 years agoMake sure a process service starts-on-console matches runs-on-console.
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.

6 years agoImplement a timeout (of 5 seconds) for log to flush on shutdown.
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.

6 years agoUpgrade bundled Dasynq to 1.1.2.
Davin McCall [Fri, 9 Feb 2018 22:04:07 +0000 (22:04 +0000)]
Upgrade bundled Dasynq to 1.1.2.

6 years agoUp version to 0.08. v0.08
Davin McCall [Sat, 3 Feb 2018 19:26:56 +0000 (19:26 +0000)]
Up version to 0.08.

6 years agoAdd "shutdown" subcommand to dinitctl.
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.

6 years agoUpdate bundled Dasynq (to 1.1.0).
Davin McCall [Sat, 3 Feb 2018 19:20:16 +0000 (19:20 +0000)]
Update bundled Dasynq (to 1.1.0).

6 years agoFix error in control protocol implementation in dinitctl/shutdown.
Davin McCall [Sat, 3 Feb 2018 18:38:48 +0000 (18:38 +0000)]
Fix error in control protocol implementation in dinitctl/shutdown.

6 years agoAdjust compile/link options.
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.

6 years agoAdd #include's to fix OpenBSD build.
Davin McCall [Sat, 3 Feb 2018 16:41:23 +0000 (16:41 +0000)]
Add #include's to fix OpenBSD build.

6 years agodinitctl: various renaming from camelCase
Davin McCall [Sat, 3 Feb 2018 16:27:27 +0000 (16:27 +0000)]
dinitctl: various renaming from camelCase

6 years agoProcess tests: check timer status in various tests.
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.

6 years agoStop the stop timer when a service stops.
Davin McCall [Thu, 25 Jan 2018 23:13:35 +0000 (23:13 +0000)]
Stop the stop timer when a service stops.

6 years agoprocess service: allow start timeout, but don't arm timer.
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).

6 years agoDisable default start timeout for process services.
Davin McCall [Wed, 24 Jan 2018 23:39:26 +0000 (23:39 +0000)]
Disable default start timeout for process services.

6 years agoRename load_service.cc to load-service.cc for consistency.
Davin McCall [Sun, 21 Jan 2018 15:34:40 +0000 (15:34 +0000)]
Rename load_service.cc to load-service.cc for consistency.

6 years agoFix processing of "run-as" parameter.
Davin McCall [Sun, 21 Jan 2018 14:34:58 +0000 (14:34 +0000)]
Fix processing of "run-as" parameter.

6 years agoMan pages: split service description format to separate man page.
Davin McCall [Sun, 21 Jan 2018 12:56:50 +0000 (12:56 +0000)]
Man pages: split service description format to separate man page.

6 years agoSupport for running services as a different user (run-as=...).
Davin McCall [Sat, 20 Jan 2018 20:42:11 +0000 (20:42 +0000)]
Support for running services as a different user (run-as=...).

6 years agoRefactoring / clean up.
Davin McCall [Fri, 19 Jan 2018 23:41:54 +0000 (23:41 +0000)]
Refactoring / clean up.

6 years agoMove some #include's around to fix build issue.
Davin McCall [Fri, 19 Jan 2018 20:15:05 +0000 (20:15 +0000)]
Move some #include's around to fix build issue.

6 years agoMove some data/functions from service_record to base_process_service.
Davin McCall [Fri, 19 Jan 2018 18:00:35 +0000 (18:00 +0000)]
Move some data/functions from service_record to base_process_service.

6 years agoRename getShutdownType function - eliminate snake case.
Davin McCall [Fri, 19 Jan 2018 10:15:25 +0000 (10:15 +0000)]
Rename getShutdownType function - eliminate snake case.

6 years agoRe-work console acquisition/release.
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.

6 years agoAdd test for console release for STARTING to STOPPED transition.
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.

6 years agoBuild: rename EXTRA_LIBS to the more conventional LDFLAGS.
Davin McCall [Thu, 18 Jan 2018 22:09:21 +0000 (22:09 +0000)]
Build: rename EXTRA_LIBS to the more conventional LDFLAGS.

6 years agoAdd example mconfig options for FreeBSD.
Davin McCall [Thu, 18 Jan 2018 21:53:45 +0000 (21:53 +0000)]
Add example mconfig options for FreeBSD.

6 years agoRenaming of some snake-case functions missed in prior rename batches.
Davin McCall [Tue, 16 Jan 2018 22:19:52 +0000 (22:19 +0000)]
Renaming of some snake-case functions missed in prior rename batches.

6 years agotests build: use dependencies auto-generated from tested sources.
Davin McCall [Tue, 16 Jan 2018 21:01:58 +0000 (21:01 +0000)]
tests build: use dependencies auto-generated from tested sources.

6 years agoMinor fixes to tests.
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.

6 years agoAdd second smooth recovery test.
Davin McCall [Tue, 16 Jan 2018 20:49:00 +0000 (20:49 +0000)]
Add second smooth recovery test.

6 years agoUpdate bundled Dasynq to 1.0.4.
Davin McCall [Tue, 16 Jan 2018 20:34:06 +0000 (20:34 +0000)]
Update bundled Dasynq to 1.0.4.

6 years agoFix smooth recovery test.
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.

6 years agoAdd process service stop timeout test.
Davin McCall [Tue, 16 Jan 2018 09:13:33 +0000 (09:13 +0000)]
Add process service stop timeout test.

6 years agoAdd a proc test, and name each 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.

6 years agoservice_record: add boolean issue_stop parameter to release function.
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).

6 years agoFix issue with process services restarting after start timeout.
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).

6 years agobaseproc-sys.h: Add explanatory comment.
Davin McCall [Mon, 15 Jan 2018 21:18:57 +0000 (21:18 +0000)]
baseproc-sys.h: Add explanatory comment.

6 years agoAdd getpgid stub to bp_sys namespace.
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.

6 years agoproctests: complete existing tests and add a 4th (currently fails).
Davin McCall [Mon, 15 Jan 2018 18:36:38 +0000 (18:36 +0000)]
proctests: complete existing tests and add a 4th (currently fails).

6 years agomake install: put manpages in correct directory.
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.

6 years agotests makefile: auto-generate dependencies (*.d) while building objects.
Davin McCall [Mon, 15 Jan 2018 18:15:33 +0000 (18:15 +0000)]
tests makefile: auto-generate dependencies (*.d) while building objects.

6 years agoImplement mock functionality for some system calls in bp_sys.
Davin McCall [Mon, 15 Jan 2018 09:10:10 +0000 (09:10 +0000)]
Implement mock functionality for some system calls in bp_sys.

6 years agoStub out system functions for testing (WIP).
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).

6 years agoMove 'run_child_proc' function into a separate source file.
Davin McCall [Sun, 14 Jan 2018 12:17:19 +0000 (12:17 +0000)]
Move 'run_child_proc' function into a separate source file.

6 years agoMove base_process_service timer expiry handling out of friend class.
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.

6 years agoAdd some process-service tests.
Davin McCall [Sat, 13 Jan 2018 16:58:12 +0000 (16:58 +0000)]
Add some process-service tests.

6 years agoUse general dinit.h header in baseproc-service.cc.
Davin McCall [Sat, 13 Jan 2018 16:47:57 +0000 (16:47 +0000)]
Use general dinit.h header in baseproc-service.cc.

6 years agoMakefile: build dependency lists (*.d) during regular build.
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.

6 years agoStub out Dasynq functionality for tests.
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.

6 years agoAdd more missing includes for tests.
Davin McCall [Sat, 13 Jan 2018 12:02:03 +0000 (12:02 +0000)]
Add more missing includes for tests.

6 years agoFix makefile typo preventing build of 'shutdown'.
Davin McCall [Fri, 12 Jan 2018 21:10:30 +0000 (21:10 +0000)]
Fix makefile typo preventing build of 'shutdown'.

6 years agotests: infrastructure for implementing mock headers.
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).

6 years agoFix some includes (for testing/general resilience).
Davin McCall [Fri, 12 Jan 2018 20:15:41 +0000 (20:15 +0000)]
Fix some includes (for testing/general resilience).

6 years agoMove includes into a separate directory.
Davin McCall [Fri, 12 Jan 2018 16:45:51 +0000 (16:45 +0000)]
Move includes into a separate directory.

6 years agoMinor cleanup: remove unnecessary aliases.
Davin McCall [Fri, 12 Jan 2018 16:24:41 +0000 (16:24 +0000)]
Minor cleanup: remove unnecessary aliases.

6 years agoPull some commonly occurring declarations into a new header file.
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.

6 years agoTests: use stubs for various functions.
Davin McCall [Thu, 11 Jan 2018 22:17:54 +0000 (22:17 +0000)]
Tests: use stubs for various functions.

6 years agoproc-service.cc: add intro comment.
Davin McCall [Thu, 11 Jan 2018 19:34:37 +0000 (19:34 +0000)]
proc-service.cc: add intro comment.

6 years agoRefactoring: split out exec_succeeded function.
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.

6 years agoMove separate_args function from header to source file.
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.

6 years agoFix build of tests.
Davin McCall [Thu, 11 Jan 2018 17:44:01 +0000 (17:44 +0000)]
Fix build of tests.

6 years agoSplit service.cc into multiple files.
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.

6 years agoFix issue with start timeouts not correctly stopping dependents.
Davin McCall [Wed, 10 Jan 2018 18:22:37 +0000 (18:22 +0000)]
Fix issue with start timeouts not correctly stopping dependents.

6 years agoBig rename/namespace cleanup.
Davin McCall [Tue, 9 Jan 2018 17:37:34 +0000 (17:37 +0000)]
Big rename/namespace cleanup.