oweals/dinit.git
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.

8 years agoOverhaul of dinit-start utility.
Davin McCall [Wed, 30 Dec 2015 00:30:19 +0000 (00:30 +0000)]
Overhaul of dinit-start utility.

It isn't yet complete, but is functional.

8 years agoInclude desired state of service in SERVICERECORD packets.
Davin McCall [Wed, 30 Dec 2015 00:29:09 +0000 (00:29 +0000)]
Include desired state of service in SERVICERECORD packets.

8 years agoFix bug in ServiceSet::loadService (only worked properly for already-loaded
Davin McCall [Wed, 30 Dec 2015 00:24:22 +0000 (00:24 +0000)]
Fix bug in ServiceSet::loadService (only worked properly for already-loaded
services) and add an accessor method for desired_state.

8 years agoFix include style for service-constants.h include
Davin McCall [Wed, 30 Dec 2015 00:16:26 +0000 (00:16 +0000)]
Fix include style for service-constants.h include

8 years agoMove service event types into service-constants.h
Davin McCall [Wed, 30 Dec 2015 00:08:39 +0000 (00:08 +0000)]
Move service event types into service-constants.h

8 years agoControl stream: Use a circular receive buffer
Davin McCall [Tue, 29 Dec 2015 12:14:37 +0000 (12:14 +0000)]
Control stream: Use a circular receive buffer

8 years agoOverhaul of the control protocol.
Davin McCall [Tue, 29 Dec 2015 10:05:58 +0000 (10:05 +0000)]
Overhaul of the control protocol.

Numeric service handles can be allocated for a service (via FINDSERVICE/LOADSERVICE
requests), and commands are issued against a service handle. Notification of events
is performed using information packets which include the relevant service handle.

8 years agoRemove obselete TODO comment.
Davin McCall [Tue, 29 Dec 2015 09:21:28 +0000 (09:21 +0000)]
Remove obselete TODO comment.

8 years agoSplit service constants (state/event enumerations) into a separate
Davin McCall [Tue, 29 Dec 2015 09:17:54 +0000 (09:17 +0000)]
Split service constants (state/event enumerations) into a separate
include file.

8 years agoPrevent force_stop state being set in a service that has already
Davin McCall [Tue, 29 Dec 2015 09:16:40 +0000 (09:16 +0000)]
Prevent force_stop state being set in a service that has already
stopped.

8 years agoAdd a publicly-accessible method to load a service (and return
Davin McCall [Mon, 28 Dec 2015 16:33:09 +0000 (16:33 +0000)]
Add a publicly-accessible method to load a service (and return
a pointer to its service record).

8 years agoFix bind of control socket, and unlink control socket path on exit
Davin McCall [Mon, 28 Dec 2015 16:15:24 +0000 (16:15 +0000)]
Fix bind of control socket, and unlink control socket path on exit

8 years agoAdd an event listener interface to services.
Davin McCall [Sun, 27 Dec 2015 11:56:21 +0000 (11:56 +0000)]
Add an event listener interface to services.

8 years agoMinor re-arrangement of fields and code documentation improvements.
Davin McCall [Thu, 24 Dec 2015 23:39:24 +0000 (23:39 +0000)]
Minor re-arrangement of fields and code documentation improvements.

8 years agoCleanup error handling / logging
Davin McCall [Wed, 23 Dec 2015 20:33:03 +0000 (20:33 +0000)]
Cleanup error handling / logging

8 years agoAdd possibility to pin services started or stopped. This prevents
Davin McCall [Tue, 1 Dec 2015 19:53:33 +0000 (19:53 +0000)]
Add possibility to pin services started or stopped. This prevents
them from automatically stopping or starting as part of a dependency
chain.

8 years agoImprove error message logged when failing to load a service (give
Davin McCall [Tue, 24 Nov 2015 11:49:52 +0000 (11:49 +0000)]
Improve error message logged when failing to load a service (give
reason for failure).

(Also correct some comments explaining util-linux-ng shutdown/init
behavior).

8 years agoAdd "nosigterm" service setting to inhibit sending SIGTERM to service
Davin McCall [Tue, 24 Nov 2015 00:03:10 +0000 (00:03 +0000)]
Add "nosigterm" service setting to inhibit sending SIGTERM to service
process. (Unless an aleternative signal is specified using 'termsignal',
no termination signal will be sent).

8 years agoAdd a "query version" command to the control protocol.
Davin McCall [Mon, 23 Nov 2015 09:43:59 +0000 (09:43 +0000)]
Add a "query version" command to the control protocol.

8 years agoAdd possibility to retrieve textual description of errors from service
Davin McCall [Mon, 23 Nov 2015 09:25:13 +0000 (09:25 +0000)]
Add possibility to retrieve textual description of errors from service
load exceptions.

8 years agoControl protocol cleanups.
Davin McCall [Mon, 23 Nov 2015 08:29:05 +0000 (08:29 +0000)]
Control protocol cleanups.

8 years agoComment update.
Davin McCall [Mon, 23 Nov 2015 07:42:13 +0000 (07:42 +0000)]
Comment update.

8 years agoFix remaining case of ControlConn being used after being deleted.
Davin McCall [Mon, 23 Nov 2015 07:39:42 +0000 (07:39 +0000)]
Fix remaining case of ControlConn being used after being deleted.

8 years agoIn processPacket() always check the response of queuePacket(), to
Davin McCall [Sun, 22 Nov 2015 14:50:13 +0000 (14:50 +0000)]
In processPacket() always check the response of queuePacket(), to
avoid writing to instance variables after the ControlConn instance
has been deleted.

Also make some functions private.

8 years agoVarious control protocol improvements, still needs significant work.
Davin McCall [Sun, 22 Nov 2015 14:27:17 +0000 (14:27 +0000)]
Various control protocol improvements, still needs significant work.

8 years agoIntroduce queuePacket() variant which takes a `const char *` buffer
Davin McCall [Sat, 21 Nov 2015 12:30:12 +0000 (12:30 +0000)]
Introduce queuePacket() variant which takes a `const char *` buffer
rather than a pre-made vector. Use it where appropriate to send ACK
responses.

8 years agoAdd function to queue outgoing packet to a control connection.
Davin McCall [Sat, 21 Nov 2015 11:29:35 +0000 (11:29 +0000)]
Add function to queue outgoing packet to a control connection.

8 years agoMove compiler flags out of the Makefile and into mconfig
Davin McCall [Thu, 19 Nov 2015 22:45:29 +0000 (22:45 +0000)]
Move compiler flags out of the Makefile and into mconfig

8 years agoVarious exception handling fixes and 'noexcept' declarations
Davin McCall [Thu, 19 Nov 2015 22:03:51 +0000 (22:03 +0000)]
Various exception handling fixes and 'noexcept' declarations

8 years agoRemove incorrect comment
Davin McCall [Thu, 19 Nov 2015 18:46:22 +0000 (18:46 +0000)]
Remove incorrect comment

8 years agoRemove functional TODO comments.
Davin McCall [Thu, 19 Nov 2015 18:42:28 +0000 (18:42 +0000)]
Remove functional TODO comments.

8 years agoAdd a control command to initiate service rollback (and receive
Davin McCall [Thu, 19 Nov 2015 18:28:34 +0000 (18:28 +0000)]
Add a control command to initiate service rollback (and receive
notification when rollback is complete).

8 years agoFix some logging, and add a variable to track how many control connections
Davin McCall [Thu, 19 Nov 2015 18:20:34 +0000 (18:20 +0000)]
Fix some logging, and add a variable to track how many control connections
are open. Don't terminate while there are still control connections.

8 years agoCommit .gitignore
Davin McCall [Thu, 19 Nov 2015 11:24:08 +0000 (11:24 +0000)]
Commit .gitignore

8 years agoAdd the "termsignal" setting to process services. This allows an
Davin McCall [Thu, 19 Nov 2015 11:02:18 +0000 (11:02 +0000)]
Add the "termsignal" setting to process services. This allows an
additional signal (alongside SIGTERM) to be sent to the process to
terminate it.

8 years agoCatch allocation exception when receiving a control socket connection
Davin McCall [Wed, 18 Nov 2015 22:40:04 +0000 (22:40 +0000)]
Catch allocation exception when receiving a control socket connection

8 years agoDocumentation updates
Davin McCall [Wed, 18 Nov 2015 17:13:05 +0000 (17:13 +0000)]
Documentation updates

8 years agoImprove the state model.
Davin McCall [Wed, 18 Nov 2015 17:07:09 +0000 (17:07 +0000)]
Improve the state model.

A service now transitions into the STARTING state from the STOPPED state
as soon as start() is called, rather than after all dependencies have
started. Similarly a service enteres the STOPPING state (from STARTED)
immediately when stop() is called.

Forced re-starts should now work properly in all cases.

8 years agoAdd 'dependencyStarted' method instead of directly overloading 'start'
Davin McCall [Wed, 18 Nov 2015 14:23:35 +0000 (14:23 +0000)]
Add 'dependencyStarted' method instead of directly overloading 'start'

8 years agoAdd sample config for OpenBSD build
Davin McCall [Tue, 17 Nov 2015 23:13:37 +0000 (23:13 +0000)]
Add sample config for OpenBSD build

8 years agoRename 'reboot' variable to 'do_reboot' to avoid conflict with OpenBSD
Davin McCall [Tue, 17 Nov 2015 23:11:50 +0000 (23:11 +0000)]
Rename 'reboot' variable to 'do_reboot' to avoid conflict with OpenBSD
'reboot' function.

8 years agoRemove unintentionally committed debug statements
Davin McCall [Tue, 17 Nov 2015 21:24:16 +0000 (21:24 +0000)]
Remove unintentionally committed debug statements

8 years agoLogging and comment fixes
Davin McCall [Tue, 17 Nov 2015 19:25:37 +0000 (19:25 +0000)]
Logging and comment fixes

8 years agoAdd dinit-log.h as a dependency for objects
Davin McCall [Tue, 17 Nov 2015 19:24:28 +0000 (19:24 +0000)]
Add dinit-log.h as a dependency for objects

8 years agoImprove logging facilities.
Davin McCall [Tue, 17 Nov 2015 19:23:29 +0000 (19:23 +0000)]
Improve logging facilities.

Allow variadic 'log' calls, and automatically convert std::string
and int arguments to char * in an exception-free manner.

8 years agoFix bug: "internal" services never properly registered that they had
Davin McCall [Tue, 17 Nov 2015 18:58:22 +0000 (18:58 +0000)]
Fix bug: "internal" services never properly registered that they had
stopped.

8 years agoUpdate README origin/HEAD origin/master
Davin McCall [Tue, 17 Nov 2015 10:46:39 +0000 (10:46 +0000)]
Update README

8 years agoUpdate TODO list
Davin McCall [Tue, 17 Nov 2015 02:01:33 +0000 (02:01 +0000)]
Update TODO list

8 years agoSeveral changes, centered around improving logging and handling
Davin McCall [Tue, 17 Nov 2015 01:55:51 +0000 (01:55 +0000)]
Several changes, centered around improving logging and handling
read-only initial filesystem.

* introduce basic logging functions
* allow "onstart" commands to specify if console output should
  stop and/or if control socket should be opened after a service
  starts
* fix a bug in load_service / service constructor interaction,
  caused services with arguments to fail

8 years agoUse C++11 typesafe enums for service type (ServiceType) and state
Davin McCall [Mon, 16 Nov 2015 00:28:41 +0000 (00:28 +0000)]
Use C++11 typesafe enums for service type (ServiceType) and state
(ServiceState).

8 years agoMake start_ps_process more C++ish and prevent it throwing exceptions
Davin McCall [Sun, 15 Nov 2015 15:42:01 +0000 (15:42 +0000)]
Make start_ps_process more C++ish and prevent it throwing exceptions

The function already has a status result so it doesn't make much
sense to allow exceptions to propogate out of it.

8 years agoAllow for quoted program arguments (and executable).
Davin McCall [Sun, 15 Nov 2015 11:28:50 +0000 (11:28 +0000)]
Allow for quoted program arguments (and executable).

In loadServiceRecord(), the 'command' setting was parsed and unquoted
resulting in a single string. Now, the beginning and end of each part
(i.e. the executable and each argument) are recorded so they can be
stored as part of the service record, and nul terminators are stored
behind each part.

8 years agoFix comment in relation to vfork (we are using fork instead now)
Davin McCall [Fri, 13 Nov 2015 18:15:34 +0000 (18:15 +0000)]
Fix comment in relation to vfork (we are using fork instead now)

8 years agoMinor cleanup: use C++-style cast and add some comments
Davin McCall [Fri, 13 Nov 2015 18:12:37 +0000 (18:12 +0000)]
Minor cleanup: use C++-style cast and add some comments

8 years agoBack out incorrect comment introduced earlier.
Davin McCall [Thu, 5 Nov 2015 00:23:35 +0000 (00:23 +0000)]
Back out incorrect comment introduced earlier.

8 years agoImprove comments - remove no longer relevant comment, add some new comments.
Davin McCall [Wed, 4 Nov 2015 22:14:58 +0000 (22:14 +0000)]
Improve comments - remove no longer relevant comment, add some new comments.

8 years agoAdd parameter documentation for read_setting_value
Davin McCall [Wed, 4 Nov 2015 22:08:37 +0000 (22:08 +0000)]
Add parameter documentation for read_setting_value

8 years agoAugment read_setting_value so that it can return the position (start and end)
Davin McCall [Wed, 4 Nov 2015 22:05:20 +0000 (22:05 +0000)]
Augment read_setting_value so that it can return the position (start and end)
of each part of the setting value.

8 years agoChange parameter type of read_setting_{name,value} from string_iterator pointer to...
Davin McCall [Wed, 4 Nov 2015 20:17:38 +0000 (20:17 +0000)]
Change parameter type of read_setting_{name,value} from string_iterator pointer to string_iterator reference.

8 years agoImprove comment.
Davin McCall [Wed, 4 Nov 2015 20:14:21 +0000 (20:14 +0000)]
Improve comment.

8 years agoAdd support for "internal" services (which don't actually run any
Davin McCall [Fri, 25 Sep 2015 19:59:16 +0000 (20:59 +0100)]
Add support for "internal" services (which don't actually run any
external process) and enhance config file parsing a little.

8 years agoRe-vamp the "build system".
Davin McCall [Mon, 14 Sep 2015 20:56:16 +0000 (21:56 +0100)]
Re-vamp the "build system".

Move compiler options etc into make variables in the "mconfig" file.
The main makefile includes the mconfig file, so it shouldn't generally
be necessary to edit the makefile itself. Includes sample config for
GCC and LLVM+libc+++.

8 years agoSimple cleanups.
Davin McCall [Mon, 14 Sep 2015 20:52:10 +0000 (21:52 +0100)]
Simple cleanups.

8 years agoFinish soft dependency support.
Davin McCall [Wed, 9 Sep 2015 19:52:23 +0000 (20:52 +0100)]
Finish soft dependency support.

If a soft dependency fails to start, it no longer cancels its
dependent's start.