oweals/dinit.git
8 years agoUpdate dasynq
Davin McCall [Mon, 13 Jun 2016 21:20:28 +0000 (22:20 +0100)]
Update dasynq

8 years agoUse a BidiFdWatcher for control connections. One step closer to
Davin McCall [Sun, 12 Jun 2016 23:57:52 +0000 (00:57 +0100)]
Use a BidiFdWatcher for control connections. One step closer to
working with kqueue...

8 years agoUpdate dasynq
Davin McCall [Sun, 12 Jun 2016 23:57:20 +0000 (00:57 +0100)]
Update dasynq

8 years agoCatch a broader range of exceptions when creating a ControlConn
Davin McCall [Sun, 12 Jun 2016 23:21:09 +0000 (00:21 +0100)]
Catch a broader range of exceptions when creating a ControlConn

8 years agoFix condition for detecting read failure in process_child_status().
Davin McCall [Sun, 12 Jun 2016 23:18:57 +0000 (00:18 +0100)]
Fix condition for detecting read failure in process_child_status().

8 years agoImplement DINIT_CP_RELEASESERVICE command.
Davin McCall [Sun, 12 Jun 2016 09:06:01 +0000 (10:06 +0100)]
Implement DINIT_CP_RELEASESERVICE command.

8 years agoCode consistency and documentation update
Davin McCall [Sun, 12 Jun 2016 09:00:49 +0000 (10:00 +0100)]
Code consistency and documentation update

8 years agoMap dinit-log log levels to syslog log levels
Davin McCall [Sat, 11 Jun 2016 20:21:25 +0000 (21:21 +0100)]
Map dinit-log log levels to syslog log levels

8 years agoEnable logging to syslog. v0.02
Davin McCall [Sat, 11 Jun 2016 19:38:22 +0000 (20:38 +0100)]
Enable logging to syslog.

8 years agoIncorporate latest bugfixes from dasynq
Davin McCall [Sat, 11 Jun 2016 18:24:02 +0000 (19:24 +0100)]
Incorporate latest bugfixes from dasynq

8 years agoFix (remove) noexcept specification for init_log().
Davin McCall [Sat, 11 Jun 2016 14:59:46 +0000 (15:59 +0100)]
Fix (remove) noexcept specification for init_log().

8 years agoFull support within the logging subsystem to an external source (fd).
Davin McCall [Sat, 11 Jun 2016 14:55:46 +0000 (15:55 +0100)]
Full support within the logging subsystem to an external source (fd).

8 years agoMore refactoring in preparation for proper logging support
Davin McCall [Sat, 11 Jun 2016 10:51:14 +0000 (11:51 +0100)]
More refactoring in preparation for proper logging support

8 years agoMinor refactoring
Davin McCall [Sat, 11 Jun 2016 10:06:54 +0000 (11:06 +0100)]
Minor refactoring

8 years agoAvoid hanging if a BGPROCESS is not a child of dinit, by probing
Davin McCall [Tue, 7 Jun 2016 07:30:00 +0000 (08:30 +0100)]
Avoid hanging if a BGPROCESS is not a child of dinit, by probing
status with waitpid() and assuming the process is stopped if it
is not a child.

8 years agoTODO updates.
Davin McCall [Mon, 6 Jun 2016 23:30:20 +0000 (00:30 +0100)]
TODO updates.

8 years agoWhitespace fixes v0.01
Davin McCall [Mon, 6 Jun 2016 22:40:51 +0000 (23:40 +0100)]
Whitespace fixes

8 years agoNo need to link libev anymore.
Davin McCall [Mon, 6 Jun 2016 22:12:18 +0000 (23:12 +0100)]
No need to link libev anymore.

8 years agoRefactoring, and actually enable console log in enable_console_log()...
Davin McCall [Mon, 6 Jun 2016 22:11:49 +0000 (23:11 +0100)]
Refactoring, and actually enable console log in enable_console_log()...

8 years agoRemove obseleted TODO comment
Davin McCall [Mon, 6 Jun 2016 19:40:39 +0000 (20:40 +0100)]
Remove obseleted TODO comment

8 years agoAdd console watch for logging once, then enable and disable as necessary,
Davin McCall [Mon, 6 Jun 2016 18:12:18 +0000 (19:12 +0100)]
Add console watch for logging once, then enable and disable as necessary,
rather than constantly adding and removing it.

8 years agoUpdate dasynq
Davin McCall [Mon, 6 Jun 2016 18:11:18 +0000 (19:11 +0100)]
Update dasynq

8 years agoCode documentation - ServiceRecord and ServiceSet. Add a few lines on how
Davin McCall [Mon, 6 Jun 2016 15:31:00 +0000 (16:31 +0100)]
Code documentation - ServiceRecord and ServiceSet. Add a few lines on how
require/release operate and control service start/stop.

8 years agoSuppress "invalid offsetof" warnings.
Davin McCall [Mon, 6 Jun 2016 07:31:48 +0000 (08:31 +0100)]
Suppress "invalid offsetof" warnings.

8 years agoRelease on failure to start.
Davin McCall [Mon, 6 Jun 2016 07:30:38 +0000 (08:30 +0100)]
Release on failure to start.
(Ensures dependencies will stop if they are not otherwise required).

8 years agoFix condition in is_log_flushed
Davin McCall [Sun, 5 Jun 2016 20:25:53 +0000 (21:25 +0100)]
Fix condition in is_log_flushed

8 years agoMake all log messages go via the log buffer.
Davin McCall [Sun, 5 Jun 2016 20:05:40 +0000 (21:05 +0100)]
Make all log messages go via the log buffer.
Flush the log buffer before exit.

8 years agoRefactorings.
Davin McCall [Sun, 5 Jun 2016 18:31:15 +0000 (19:31 +0100)]
Refactorings.

8 years agoFix style inconsistency in CPBuffer: fillTo -> fill_to
Davin McCall [Sun, 5 Jun 2016 17:28:36 +0000 (18:28 +0100)]
Fix style inconsistency in CPBuffer: fillTo -> fill_to

There is generally inconsistent style throughout the codebase, but
at least this one class can be self-consistent...

8 years agoOpenBSD: use __thrsigdivert as a replacement for sigtimedwait.
Davin McCall [Sun, 5 Jun 2016 14:32:48 +0000 (15:32 +0100)]
OpenBSD: use __thrsigdivert as a replacement for sigtimedwait.

8 years agoMake selection of epoll/kqueue backend automatic
Davin McCall [Sun, 5 Jun 2016 09:31:00 +0000 (10:31 +0100)]
Make selection of epoll/kqueue backend automatic

8 years agoBeginnings of kqueue support (far from complete)
Davin McCall [Sun, 5 Jun 2016 02:29:12 +0000 (03:29 +0100)]
Beginnings of kqueue support (far from complete)

8 years agoRip out libev, replace with dasynq (new library written for the purpose).
Davin McCall [Sun, 5 Jun 2016 00:49:23 +0000 (01:49 +0100)]
Rip out libev, replace with dasynq (new library written for the purpose).

8 years agoRefactoring. Move buffered output management (variables) into a
Davin McCall [Tue, 19 Jan 2016 19:13:18 +0000 (19:13 +0000)]
Refactoring. Move buffered output management (variables) into a
class.

8 years agoUse non-blocking I/O and event notification for console logging.
Davin McCall [Tue, 19 Jan 2016 11:13:55 +0000 (11:13 +0000)]
Use non-blocking I/O and event notification for console logging.
(needs some cleanup).

8 years agoOnly enable console logging via the service layer (when no services
Davin McCall [Sat, 16 Jan 2016 14:45:52 +0000 (14:45 +0000)]
Only enable console logging via the service layer (when no services
are using the console).

8 years agoIntroduce method to enable/disable console logging, instead of
Davin McCall [Sat, 16 Jan 2016 14:17:20 +0000 (14:17 +0000)]
Introduce method to enable/disable console logging, instead of
using a global variable. (introduce "enable_console_log(bool)",
remove "log_to_console").

8 years agoAdd/correct some comments
Davin McCall [Sat, 16 Jan 2016 13:47:08 +0000 (13:47 +0000)]
Add/correct some comments

8 years agoMake CPBuffer a template, parameterized by buffer size
Davin McCall [Sat, 16 Jan 2016 12:54:05 +0000 (12:54 +0000)]
Make CPBuffer a template, parameterized by buffer size

8 years agoMakefile improvements (fix clean target), and build with -fno-rtti
Davin McCall [Fri, 15 Jan 2016 19:26:16 +0000 (19:26 +0000)]
Makefile improvements (fix clean target), and build with -fno-rtti
for reduced binary size.

8 years agoUse $HOME/dinit.d for default service directory if not system init.
Davin McCall [Fri, 15 Jan 2016 11:49:46 +0000 (11:49 +0000)]
Use $HOME/dinit.d for default service directory if not system init.
Add command line options to specify service directory and control
socket path. Add command line option to run as system init (default
when pid == 1).

8 years agoRemove some explicit memory deallocation in favor of using unique_ptr.
Davin McCall [Thu, 14 Jan 2016 18:19:41 +0000 (18:19 +0000)]
Remove some explicit memory deallocation in favor of using unique_ptr.

8 years agoUse delete[] to delete buffers allocated via new[]
Davin McCall [Thu, 14 Jan 2016 10:02:40 +0000 (10:02 +0000)]
Use delete[] to delete buffers allocated via new[]
(thank you LLVM static analyzer...)

8 years agoRemove std::move(...) so that copy ellision can occur.
Davin McCall [Thu, 14 Jan 2016 10:02:06 +0000 (10:02 +0000)]
Remove std::move(...) so that copy ellision can occur.

8 years agoAdd support for unpin command in dinitctl (includes corresponding
Davin McCall [Wed, 13 Jan 2016 20:02:14 +0000 (20:02 +0000)]
Add support for unpin command in dinitctl (includes corresponding
control protocol changes)

8 years agoAdd support for pinning services to dinitctl
Davin McCall [Wed, 13 Jan 2016 18:51:10 +0000 (18:51 +0000)]
Add support for pinning services to dinitctl

8 years agoMake "pinStart" and "start", and "pinStop" and "stop", separate
Davin McCall [Wed, 13 Jan 2016 18:49:40 +0000 (18:49 +0000)]
Make "pinStart" and "start", and "pinStop" and "stop", separate
operations.

"pinStart" and "pinStop" set the pin for the started and stopped
states respectively, but do not attempt to move the service into
the chosen state.

8 years agoUpdate README with info on service hierarchy and service states
Davin McCall [Tue, 12 Jan 2016 09:54:35 +0000 (09:54 +0000)]
Update README with info on service hierarchy and service states
(especially active vs inactive)

8 years agoMark service active if it is started while not active.
Davin McCall [Tue, 12 Jan 2016 08:56:10 +0000 (08:56 +0000)]
Mark service active if it is started while not active.
(It will mark itself inactive when it stops).

8 years agoDuring shutdown, let process attrition occur naturally, instead of forcing
Davin McCall [Tue, 12 Jan 2016 00:58:55 +0000 (00:58 +0000)]
During shutdown, let process attrition occur naturally, instead of forcing
the services down early.

Also, don't restart a service which has desired_state = STARTED if auto-restart
is disabled.

8 years agoVarious changes to match changes to command protocol.
Davin McCall [Mon, 11 Jan 2016 23:56:04 +0000 (23:56 +0000)]
Various changes to match changes to command protocol.

8 years agoRefactor/fix control commands, add a few start/stop alternatives
Davin McCall [Mon, 11 Jan 2016 23:52:36 +0000 (23:52 +0000)]
Refactor/fix control commands, add a few start/stop alternatives

8 years agoFix stop(). Give it a boolean argument for 2 modes of operation:
Davin McCall [Mon, 11 Jan 2016 23:46:00 +0000 (23:46 +0000)]
Fix stop(). Give it a boolean argument for 2 modes of operation:
One, release the service if it was explicitly started (which will
 bring it down only if it is no longer needed by any active service)
Two, release the service and bring it down (which will also bring
 down any dependent services).

8 years agoMake sure to initialise all members of ControlConn
Davin McCall [Mon, 11 Jan 2016 22:59:24 +0000 (22:59 +0000)]
Make sure to initialise all members of ControlConn

8 years agoRestore "restart" flag functionality. Services no longer auto-restart
Davin McCall [Mon, 11 Jan 2016 22:21:16 +0000 (22:21 +0000)]
Restore "restart" flag functionality. Services no longer auto-restart
just because they are active (required) - they now only do so if
the auto-restart flag has been set for the service.

8 years agoCleanups and refactoring.
Davin McCall [Mon, 11 Jan 2016 20:00:40 +0000 (20:00 +0000)]
Cleanups and refactoring.

8 years agoLargish re-work of how dependencies are handled. The "start" and
Davin McCall [Mon, 11 Jan 2016 19:38:12 +0000 (19:38 +0000)]
Largish re-work of how dependencies are handled. The "start" and
"dependentStopped" methods were overloaded in unsound ways.

Add require() and release() methods to make an explicit requirement
on a dependency. A require() is added when the service is explictly
started, or when it is a dependency of such a service (directly),
or when it is a dependency of a service which has been required.

8 years agoFix "skip to reply packet" method.
Davin McCall [Sun, 10 Jan 2016 11:49:23 +0000 (11:49 +0000)]
Fix "skip to reply packet" method.

It was possible to skip over an information packet but not read any
further reply, so the packet type test (rbuffer[0] == ...) would not
work correctly.

8 years agoRefactoring, and one fix: stopping an already-stopped service can be
Davin McCall [Sat, 9 Jan 2016 19:59:36 +0000 (19:59 +0000)]
Refactoring, and one fix: stopping an already-stopped service can be
used to remove its explicitly-started state, and in that case needs
to notify dependencies of complete shutdown.

8 years agoIntroduce "explicitly started" state flag for services, and automatically
Davin McCall [Sat, 9 Jan 2016 18:20:48 +0000 (18:20 +0000)]
Introduce "explicitly started" state flag for services, and automatically
stop services which were not explicitly started when they have no
dependents running.

This means that if you start a service, and then stop that service, the
system should return to its original state with no additional services
running.

8 years agoFix protocol errors in dinitctl
Davin McCall [Thu, 7 Jan 2016 23:06:54 +0000 (23:06 +0000)]
Fix protocol errors in dinitctl

8 years agoAdd license (Apache license version 2.0).
Davin McCall [Thu, 7 Jan 2016 22:08:40 +0000 (22:08 +0000)]
Add license (Apache license version 2.0).

8 years agoUpdate gitignore
Davin McCall [Thu, 7 Jan 2016 22:08:10 +0000 (22:08 +0000)]
Update gitignore

8 years agoMake sure to not write a partial command packet.
Davin McCall [Thu, 7 Jan 2016 22:02:05 +0000 (22:02 +0000)]
Make sure to not write a partial command packet.

8 years agodinitctl: recognize and report FAILEDSTART events.
Davin McCall [Thu, 7 Jan 2016 21:34:23 +0000 (21:34 +0000)]
dinitctl: recognize and report FAILEDSTART events.

8 years agoRefactoring: remove unneeded method
Davin McCall [Thu, 7 Jan 2016 20:45:09 +0000 (20:45 +0000)]
Refactoring: remove unneeded method

8 years agoMake "dinitctl start" start a service and "dinitctl stop" stop a
Davin McCall [Thu, 7 Jan 2016 10:52:31 +0000 (10:52 +0000)]
Make "dinitctl start" start a service and "dinitctl stop" stop a
service, rather than the other way around...

8 years agoChange command line and implement stopping of services in dinitctl.
Davin McCall [Wed, 6 Jan 2016 22:07:56 +0000 (22:07 +0000)]
Change command line and implement stopping of services in dinitctl.

"dinitctl start <servicename>" and "dinit stop <servicename>" now function
as you'd expect.

8 years agoRename dinit-start to dinitctl, as I think one command for service
Davin McCall [Wed, 6 Jan 2016 19:08:46 +0000 (19:08 +0000)]
Rename dinit-start to dinitctl, as I think one command for service
management is probably the best route to take.

8 years agoMove source files int src directory
Davin McCall [Tue, 5 Jan 2016 23:55:05 +0000 (23:55 +0000)]
Move source files int src directory

8 years agoAdd socket-uid and socket-gid service settings for controlling
Davin McCall [Mon, 4 Jan 2016 13:50:24 +0000 (13:50 +0000)]
Add socket-uid and socket-gid service settings for controlling
activation socket ownership.

8 years agoUpdate TODO list
Davin McCall [Mon, 4 Jan 2016 00:13:06 +0000 (00:13 +0000)]
Update TODO list

8 years agoImplement socket activation (single, unix-family socket only)
Davin McCall [Mon, 4 Jan 2016 00:01:43 +0000 (00:01 +0000)]
Implement socket activation (single, unix-family socket only)

8 years agoAdd some info about Nosh, another init/service system I just found out about.
Davin McCall [Sun, 3 Jan 2016 23:16:14 +0000 (23:16 +0000)]
Add some info about Nosh, another init/service system I just found out about.

8 years agoMake sure to initialise all state bits
Davin McCall [Sun, 3 Jan 2016 16:39:35 +0000 (16:39 +0000)]
Make sure to initialise all state bits

8 years agoA forced stop at the point of reaching STARTED state should not
Davin McCall [Sun, 3 Jan 2016 16:16:21 +0000 (16:16 +0000)]
A forced stop at the point of reaching STARTED state should not
actually change the desired state: call start() after stop() if
the desired state is not STOPPED.

8 years agoRe-read PID file after recovering a BGPROCESS service.
Davin McCall [Sun, 3 Jan 2016 16:06:31 +0000 (16:06 +0000)]
Re-read PID file after recovering a BGPROCESS service.

8 years agoUpdate TODO (log messages to console should be buffered when a service
Davin McCall [Sun, 3 Jan 2016 11:34:15 +0000 (11:34 +0000)]
Update TODO (log messages to console should be buffered when a service
is holding the console)

8 years agoMinor re-organisation and logging improvements
Davin McCall [Sun, 3 Jan 2016 11:30:53 +0000 (11:30 +0000)]
Minor re-organisation and logging improvements

8 years agoAdd support for "bgprocess" services - daemons which fork and put
Davin McCall [Sun, 3 Jan 2016 01:37:46 +0000 (01:37 +0000)]
Add support for "bgprocess" services - daemons which fork and put
themselves in the background (but which ideally write their PID
into a file that can be read by Dinit).

8 years agoIf a "scripted" service has no stop command, allow it to stop immediately.
Davin McCall [Sat, 2 Jan 2016 18:41:05 +0000 (18:41 +0000)]
If a "scripted" service has no stop command, allow it to stop immediately.

This allows no stop command to be specified if none is needed. (This probably
already worked, but only because Dinit would try to exec "" (the empty string)
when the service stopped, which would fail, and the service would get marked
as stopped anyway).

8 years agoWhen performing shutdown, un-pin services after issuing stop.
Davin McCall [Sat, 2 Jan 2016 18:10:53 +0000 (18:10 +0000)]
When performing shutdown, un-pin services after issuing stop.

8 years agoFix: scripted service might not have its start/stop registered
Davin McCall [Sat, 2 Jan 2016 17:22:51 +0000 (17:22 +0000)]
Fix: scripted service might not have its start/stop registered
if the script finishes too quickly.

8 years agoAdd "smooth-recovery" option for process services.
Davin McCall [Sat, 2 Jan 2016 13:24:31 +0000 (13:24 +0000)]
Add "smooth-recovery" option for process services.

A process service with smooth-recovery set will restart its
process (if it dies unexpectedly) without bring the service
itself down. I.e the service remains in STARTED state, and
any dependents do not have to be brought down.

8 years agoMove to asynchronous handling of child exec status.
Davin McCall [Sat, 2 Jan 2016 11:12:16 +0000 (11:12 +0000)]
Move to asynchronous handling of child exec status.

This gives ever-so-slightly better parallelism, and staves off
potential future priority inversion problems.

8 years agoRemove the "release_console" on-start flag. It is now redundant.
Davin McCall [Fri, 1 Jan 2016 18:44:25 +0000 (18:44 +0000)]
Remove the "release_console" on-start flag. It is now redundant.

8 years agoVarious improvements to state transitions.
Davin McCall [Fri, 1 Jan 2016 18:11:07 +0000 (18:11 +0000)]
Various improvements to state transitions.

Introduce a new variable to track if a service is waiting for its
dependencies (starting) or dependents (stopping). In these cases
it is possible to transition directly from STARTING to STOPPED or
from STOPPING to STARTED. This also removes the need for special
handling of "internal" services (which will never transition from
STARTING to STARTED or STOPPING to STOPPED excet via transitions
of their dependencies/dependents).

8 years agoRun "run-on-console" services as a new process group/session so
Davin McCall [Fri, 1 Jan 2016 16:32:21 +0000 (16:32 +0000)]
Run "run-on-console" services as a new process group/session so
that ^C can be used to interrupt it.

(Probably will make this optional, later).

8 years agoDon't reque for console immediately if we acquire it when dependencies
Davin McCall [Fri, 1 Jan 2016 14:58:51 +0000 (14:58 +0000)]
Don't reque for console immediately if we acquire it when dependencies
haven't started.

The theory was that we could append to the end of the queue. In practice,
though, we might be the only service in the queue, in which case
we'll immediately acquire the console if we queue for it and so go
into infinite recursion.

8 years agoI could swear I fixed this not too long ago...
Davin McCall [Fri, 1 Jan 2016 04:23:38 +0000 (04:23 +0000)]
I could swear I fixed this not too long ago...

8 years agoFix another hanging state: "internal" services can be stopped
Davin McCall [Fri, 1 Jan 2016 04:01:34 +0000 (04:01 +0000)]
Fix another hanging state: "internal" services can be stopped
while they are starting and immediately transition from
STARTING to STOPPED. If this is not allowed, they hang in
STARTING state.

(Other service types eventually start due to an external event,
and can then stop).

8 years agoAdd "run-on-console" service option, to specify that a service
Davin McCall [Fri, 1 Jan 2016 02:16:00 +0000 (02:16 +0000)]
Add "run-on-console" service option, to specify that a service
runs on the console.

Only one service can be running on the console at a time, so
there is a queue to obtain the console.

Not 100% complete yet. Part of the functionality seems to have
crept in with previous commit though? git gremlins...

8 years agoFix a problem that left services incorrectly marked as active.
Davin McCall [Fri, 1 Jan 2016 02:13:37 +0000 (02:13 +0000)]
Fix a problem that left services incorrectly marked as active.

8 years agoFor scripted services, accept both a "command" and "stop-command" setting.
Davin McCall [Thu, 31 Dec 2015 23:50:24 +0000 (23:50 +0000)]
For scripted services, accept both a "command" and "stop-command" setting.
Do not automatically add "start" or "stop" to the command.

8 years agoFix: when a dependency failed, the dependent process was not marked
Davin McCall [Thu, 31 Dec 2015 23:28:48 +0000 (23:28 +0000)]
Fix: when a dependency failed, the dependent process was not marked
as inactive.

8 years agoMerge "shutdown" and "dinit-reboot" functionality into the "shutdown"
Davin McCall [Thu, 31 Dec 2015 22:09:51 +0000 (22:09 +0000)]
Merge "shutdown" and "dinit-reboot" functionality into the "shutdown"
executable.

dinit-reboot function (of actually unmounting file systems and performing
shutdown) is accessed using --system argument, which is not expected to
be used by users.

8 years agoImplement a shutdown commoand which issues a shutdown via Dinit's
Davin McCall [Wed, 30 Dec 2015 22:24:54 +0000 (22:24 +0000)]
Implement a shutdown commoand which issues a shutdown via Dinit's
control protocol. Includes 'halt' and 'reboot' alias scripts.

Implement a dinit-reboot helper program to be called by the main
Dinit process to actually perform shutdown.

8 years agoControl protocol: Remove 'ROLLBACK' command, add a 'SHUTDOWN'
Davin McCall [Wed, 30 Dec 2015 22:22:04 +0000 (22:22 +0000)]
Control protocol: Remove 'ROLLBACK' command, add a 'SHUTDOWN'
command to replace it. Remove the rollback handler interface
from ServiceSet.

8 years agoRecord shutdown type (halt, poweroff, reboot) in the service set.
Davin McCall [Wed, 30 Dec 2015 22:18:14 +0000 (22:18 +0000)]
Record shutdown type (halt, poweroff, reboot) in the service set.

8 years agoDocumentation updates.
Davin McCall [Wed, 30 Dec 2015 00:35:32 +0000 (00:35 +0000)]
Documentation updates.