oweals/dinit.git
7 years agoLimit number of restarts within an interval
Davin McCall [Mon, 5 Jun 2017 09:26:23 +0000 (10:26 +0100)]
Limit number of restarts within an interval

7 years agoBuild: Use CXXPOPTS when generating dependency files
Davin McCall [Mon, 5 Jun 2017 09:25:43 +0000 (10:25 +0100)]
Build: Use CXXPOPTS when generating dependency files

7 years agoFix: grant console correctly
Davin McCall [Sat, 3 Jun 2017 09:28:58 +0000 (10:28 +0100)]
Fix: grant console correctly

Services marked "starts-on-console" need to be given console access.
Services that restart via "smooth recovery" need to be given console
access if they run-on-console.

7 years agoUpdate gitignore file
Davin McCall [Sat, 3 Jun 2017 08:44:35 +0000 (09:44 +0100)]
Update gitignore file

7 years agoBuild: autogenerate dependency files (*.d)
Davin McCall [Sat, 3 Jun 2017 08:43:05 +0000 (09:43 +0100)]
Build: autogenerate dependency files (*.d)

7 years agoSeparate "runs-on-console" into runs-on- and starts-on- options.
Davin McCall [Fri, 2 Jun 2017 18:39:07 +0000 (19:39 +0100)]
Separate "runs-on-console" into runs-on- and starts-on- options.

7 years agoUse restart timer also for non-smooth-recovery restarts.
Davin McCall [Fri, 2 Jun 2017 18:13:46 +0000 (19:13 +0100)]
Use restart timer also for non-smooth-recovery restarts.

7 years agoCorrect calculation of restart timeout, and up timeout to 200ms.
Davin McCall [Fri, 2 Jun 2017 17:49:13 +0000 (18:49 +0100)]
Correct calculation of restart timeout, and up timeout to 200ms.

7 years agoMinor refactoring / code documentation.
Davin McCall [Thu, 1 Jun 2017 22:02:15 +0000 (23:02 +0100)]
Minor refactoring / code documentation.

7 years agoAdd a restart timer to limit restart rate.
Davin McCall [Thu, 1 Jun 2017 19:14:05 +0000 (20:14 +0100)]
Add a restart timer to limit restart rate.

So far, applied only to "smooth recovery" restarts.

7 years agoREADME: improve wording in one paragraph.
Davin McCall [Thu, 1 Jun 2017 10:11:17 +0000 (11:11 +0100)]
README: improve wording in one paragraph.

7 years agoFix callback method name per Dasynq changes
Davin McCall [Thu, 1 Jun 2017 08:28:08 +0000 (09:28 +0100)]
Fix callback method name per Dasynq changes

7 years agoIncorporate Dasynq changes
Davin McCall [Thu, 1 Jun 2017 07:52:22 +0000 (08:52 +0100)]
Incorporate Dasynq changes

7 years agoClean up one TODO
Davin McCall [Tue, 30 May 2017 10:19:45 +0000 (11:19 +0100)]
Clean up one TODO

7 years agoSimplify allDepStarted logic.
Davin McCall [Tue, 30 May 2017 10:10:23 +0000 (11:10 +0100)]
Simplify allDepStarted logic.

Change default action of start_ps_process to call started(). This is
overriden in base_process_service to launch the process.

7 years agoservice record: move read_pid_file into bgproc_service
Davin McCall [Tue, 30 May 2017 09:29:31 +0000 (10:29 +0100)]
service record: move read_pid_file into bgproc_service

7 years agoservice_record: declare handle_exit_status as pure virtual.
Davin McCall [Tue, 30 May 2017 09:17:23 +0000 (10:17 +0100)]
service_record: declare handle_exit_status as pure virtual.

7 years agoRefactoring: create base_process_service
Davin McCall [Fri, 26 May 2017 18:20:35 +0000 (19:20 +0100)]
Refactoring: create base_process_service

This serves as a base for the three service types which start processes.

7 years agoAvoid releasing console twice on failure to read pid file.
Davin McCall [Fri, 26 May 2017 17:58:54 +0000 (18:58 +0100)]
Avoid releasing console twice on failure to read pid file.

7 years agoFix various missing std::move's (which was an exception safety issue)
Davin McCall [Fri, 26 May 2017 17:34:19 +0000 (18:34 +0100)]
Fix various missing std::move's (which was an exception safety issue)

7 years agoBreak out scripted service as a separate class
Davin McCall [Fri, 26 May 2017 09:29:13 +0000 (10:29 +0100)]
Break out scripted service as a separate class

7 years agoFix pointer bug in logging.
Davin McCall [Wed, 24 May 2017 08:17:31 +0000 (09:17 +0100)]
Fix pointer bug in logging.

7 years agoRefactoring.
Davin McCall [Tue, 23 May 2017 23:19:34 +0000 (00:19 +0100)]
Refactoring.

Move BGPROCESS and PROCESS service records to separate subclasses of
ServiceRecord.

7 years agoMinor cleanups.
Davin McCall [Tue, 23 May 2017 09:28:21 +0000 (10:28 +0100)]
Minor cleanups.

7 years agoProvide and use fallbacks for POSIX functions extended by linux/BSD.
Davin McCall [Wed, 26 Apr 2017 09:35:29 +0000 (10:35 +0100)]
Provide and use fallbacks for POSIX functions extended by linux/BSD.

accept4 isn't standard; Linux and OpenBSD have extensions to socket and
socketpair which allow opening in nonblocking/close-on-exec modes.
Implement adaptor functions which also work when these extensions aren't
present.

7 years agoIncorporate Dasynq library changes.
Davin McCall [Wed, 26 Apr 2017 09:33:00 +0000 (10:33 +0100)]
Incorporate Dasynq library changes.

7 years agoREADME: add instructions on using dinitctl utility. v0.05
Davin McCall [Thu, 30 Mar 2017 10:26:36 +0000 (11:26 +0100)]
README: add instructions on using dinitctl utility.

7 years agoRework acquire/release handling.
Davin McCall [Wed, 29 Mar 2017 15:59:52 +0000 (16:59 +0100)]
Rework acquire/release handling.

Now a service that is released releases its own dependencies immediately,
instead of after it stops. This prevents those dependencies from restarting
unnecessarily if they die/are killed in the meantime.

7 years agoUpdate TODO.
Davin McCall [Wed, 29 Mar 2017 11:54:57 +0000 (12:54 +0100)]
Update TODO.

7 years agolinux service scripts: remount /proc after intial mount
Davin McCall [Mon, 27 Mar 2017 21:24:59 +0000 (22:24 +0100)]
linux service scripts: remount /proc after intial mount

The "hidepid=1" mount option to /proc doesn't appear to take effect on the
first mount. May be a kernel or "mount" bug. In the meantime, workaround it
by remounting immediately with the desired option.

7 years agoUpdate Dasynq library and API usage
Davin McCall [Mon, 27 Mar 2017 21:24:13 +0000 (22:24 +0100)]
Update Dasynq library and API usage

Hopefully for the last time, as the Dasynq API is now stable.

7 years agoUpdate Dasynq library, and API usage throughout.
Davin McCall [Sun, 19 Mar 2017 22:23:49 +0000 (22:23 +0000)]
Update Dasynq library, and API usage throughout.

7 years agoRelease soft dependencies if they stop early.
Davin McCall [Sun, 19 Mar 2017 14:12:51 +0000 (14:12 +0000)]
Release soft dependencies if they stop early.

7 years agoAdd missed dasynq file (for OpenBSD).
Davin McCall [Sun, 12 Mar 2017 23:31:10 +0000 (23:31 +0000)]
Add missed dasynq file (for OpenBSD).

7 years agoUpdate dasynq library, and make appropriate changes in dinit code.
Davin McCall [Sun, 12 Mar 2017 23:16:34 +0000 (23:16 +0000)]
Update dasynq library, and make appropriate changes in dinit code.

7 years agoFix trivial memory leak.
Davin McCall [Sun, 12 Mar 2017 23:16:15 +0000 (23:16 +0000)]
Fix trivial memory leak.

8 years agoRun not-on-console services in a session (via setsid()).
Davin McCall [Thu, 10 Nov 2016 02:34:32 +0000 (02:34 +0000)]
Run not-on-console services in a session (via setsid()).

This prevents them from receiving terminal control signals, if
dinit is running on a terminal (normally only if run in user
mode).

8 years agoUpdate version : 0.04
Davin McCall [Wed, 9 Nov 2016 20:29:01 +0000 (20:29 +0000)]
Update version : 0.04

8 years agoIncorporate Dasynq changes (v0.02) v0.04
Davin McCall [Wed, 9 Nov 2016 20:19:36 +0000 (20:19 +0000)]
Incorporate Dasynq changes (v0.02)

8 years agoCheck for state STARTING before calling started() when process status
Davin McCall [Wed, 9 Nov 2016 15:17:54 +0000 (15:17 +0000)]
Check for state STARTING before calling started() when process status
fd closes.

A smooth-recovery process should not reported started when it recovers
(state is already STARTED). Furthermore, a service could be stopped
during smooth recovery, in which case the state will be STOPPING and
the service should certainly not transition to STARTED.

8 years agoCombine start/stop queues, and add propagation queue.
Davin McCall [Wed, 9 Nov 2016 14:28:48 +0000 (14:28 +0000)]
Combine start/stop queues, and add propagation queue.

The propagation queue is used to propagate changes other than
immediate start/stop requests. It might be possible to combine the
two queues at a later stage.

This commit eliminates all recursion from service.cc.

8 years agoCheck desired state == started before allowing service to begin
Davin McCall [Tue, 8 Nov 2016 23:15:52 +0000 (23:15 +0000)]
Check desired state == started before allowing service to begin
smooth recovery.

8 years agorootfscheck service: use the passed-from-parent control socket file descriptor
Davin McCall [Wed, 21 Sep 2016 07:23:30 +0000 (08:23 +0100)]
rootfscheck service: use the passed-from-parent control socket file descriptor
to issue reboot commands (--use-passed-cfd option to reboot).

This may be necessary since the control socket may not have been created yet, due
to the root filesystem being read-only at this point.

8 years agoAdd an option to shutdown to allow for receiving the control socket file
Davin McCall [Wed, 21 Sep 2016 07:17:28 +0000 (08:17 +0100)]
Add an option to shutdown to allow for receiving the control socket file
descriptor from the parent process (identified by DINIT_CS_FD).

8 years agoRemove use of strcpy in favour of memcpy (save the relevant string lengths
Davin McCall [Thu, 30 Jun 2016 14:20:56 +0000 (15:20 +0100)]
Remove use of strcpy in favour of memcpy (save the relevant string lengths
when they are calculated beforehand, so that they can be used as the length
argument). This is slightly more efficient and will silence and OpenBSD linker
warning.

8 years agoFix a TODO comment
Davin McCall [Mon, 27 Jun 2016 12:02:18 +0000 (13:02 +0100)]
Fix a TODO comment

8 years agoAdd a "pass-cs-fd" service option, which passes a control socket file
Davin McCall [Sun, 26 Jun 2016 18:21:10 +0000 (19:21 +0100)]
Add a "pass-cs-fd" service option, which passes a control socket file
descriptor directly to service processes, allowing them issue commands
even if the regular control socket has not been created (or if they
will not have permission to access it).

This has limited use cases and has security implications when used,
but allows early launching of a service which can pass events / issue
commands to dinit. In particular this could be useful for a device
watcher daemon which starts services as certain devices come online
(eg check and mount disks as they are detected by the kernel).

8 years agoRemove activated state if a service stops naturally
Davin McCall [Fri, 24 Jun 2016 15:30:27 +0000 (16:30 +0100)]
Remove activated state if a service stops naturally
(if auto-restart is enabled, it will restart instead).

8 years agoAdd release/wake commands to dinitctl
Davin McCall [Fri, 24 Jun 2016 15:14:28 +0000 (16:14 +0100)]
Add release/wake commands to dinitctl

8 years agoUse getWatchFd() from dasynq::FdWatcher rather than storing the fd in
Davin McCall [Fri, 24 Jun 2016 12:39:13 +0000 (13:39 +0100)]
Use getWatchFd() from dasynq::FdWatcher rather than storing the fd in
a separate member variable, in various places.
Squashes some TODOs.

8 years agoClean up signal and fd handling around fork().
Davin McCall [Thu, 23 Jun 2016 22:40:28 +0000 (23:40 +0100)]
Clean up signal and fd handling around fork().
Mask signals while we are doing dup() since it is allowed to return
EINTR apparently.
Make sure we obtain fds for stdin/stdout/stderr before we exec().

8 years agoLatest Dasynq updates
Davin McCall [Thu, 23 Jun 2016 22:38:27 +0000 (23:38 +0100)]
Latest Dasynq updates

8 years agoIgnore SIGTSTP (^Z) for run-on-console processes.
Davin McCall [Thu, 23 Jun 2016 20:25:36 +0000 (21:25 +0100)]
Ignore SIGTSTP (^Z) for run-on-console processes.
We don't want to be job control shell.

8 years agoImplement "list services" command in control protocol, and use it in
Davin McCall [Thu, 23 Jun 2016 11:33:36 +0000 (12:33 +0100)]
Implement "list services" command in control protocol, and use it in
"dinitctl list" command.

8 years agoIgnore SIGPIPE to prevent sudden exit when control socket is closed
Davin McCall [Thu, 23 Jun 2016 10:33:30 +0000 (11:33 +0100)]
Ignore SIGPIPE to prevent sudden exit when control socket is closed

8 years agoFix bug in buffer pointer calculation
Davin McCall [Thu, 23 Jun 2016 10:00:32 +0000 (11:00 +0100)]
Fix bug in buffer pointer calculation

8 years agoReport (instead of silently ignoring) various errors when reading service descriptions.
Davin McCall [Wed, 22 Jun 2016 16:22:05 +0000 (17:22 +0100)]
Report (instead of silently ignoring) various errors when reading service descriptions.
Squashes a bunch of TODO's.

8 years agoUpdate Linux documentation
Davin McCall [Wed, 22 Jun 2016 08:20:41 +0000 (09:20 +0100)]
Update Linux documentation

8 years agoRemove redundant service settings.
Davin McCall [Wed, 22 Jun 2016 08:08:29 +0000 (09:08 +0100)]
Remove redundant service settings.
Change "nosigterm" option to "no-sigterm".

8 years agoMake SIGQUIT perform immediate shutdown ("shutdown --sytem"), rather than exec()int
Davin McCall [Tue, 21 Jun 2016 18:52:02 +0000 (19:52 +0100)]
Make SIGQUIT perform immediate shutdown ("shutdown --sytem"), rather than exec()int
the plain "shutdown" command, which would have tried to contact Dinit in order to
roll back services anyway.

8 years agoCorrect exit status checks (status 0 returned by wait() doesn't have to mean
Davin McCall [Tue, 21 Jun 2016 18:24:10 +0000 (19:24 +0100)]
Correct exit status checks (status 0 returned by wait() doesn't have to mean
"exited cleanly with 0 exit status", though it probably does on most real
systems).

8 years agoLog some error conditions (kill some TODOs)
Davin McCall [Tue, 21 Jun 2016 15:11:10 +0000 (16:11 +0100)]
Log some error conditions (kill some TODOs)

8 years agoUpdate Dasynq
Davin McCall [Tue, 21 Jun 2016 13:25:19 +0000 (14:25 +0100)]
Update Dasynq

8 years agoClean up some TODOs
Davin McCall [Tue, 21 Jun 2016 08:32:16 +0000 (09:32 +0100)]
Clean up some TODOs

8 years agoScratch one TODO: default case in switch can't occur, function is only
Davin McCall [Mon, 20 Jun 2016 22:12:45 +0000 (23:12 +0100)]
Scratch one TODO: default case in switch can't occur, function is only
called once command has been established, therefore there's no need
to handle other cases.

8 years agoAdd documentation: using Dinit as your system init on Linux
Davin McCall [Sun, 19 Jun 2016 22:01:28 +0000 (23:01 +0100)]
Add documentation: using Dinit as your system init on Linux

8 years agoOne less TODO
Davin McCall [Sun, 19 Jun 2016 19:14:36 +0000 (20:14 +0100)]
One less TODO

8 years agoMerge branch 'master' of https://github.com/davmac314/dinit
Davin McCall [Sun, 19 Jun 2016 19:13:09 +0000 (20:13 +0100)]
Merge branch 'master' of https://github.com/davmac314/dinit

8 years agoFix kqueue backend bug; wasn't disabling read/write channels of a
Davin McCall [Sun, 19 Jun 2016 19:11:17 +0000 (20:11 +0100)]
Fix kqueue backend bug; wasn't disabling read/write channels of a
Bidi watcher appropriately when watcher added

8 years agoFix build problems with kqueue backend
Davin McCall [Sun, 19 Jun 2016 17:50:10 +0000 (18:50 +0100)]
Fix build problems with kqueue backend

8 years agoAdd root level Makefile, make "shutdown" be optionally built by "make all"
Davin McCall [Sun, 19 Jun 2016 17:05:01 +0000 (18:05 +0100)]
Add root level Makefile, make "shutdown" be optionally built by "make all"
(BUILD_SHUTDOWN in mconfig)

8 years agoRe-vamp shutdown
Davin McCall [Sun, 19 Jun 2016 16:44:05 +0000 (17:44 +0100)]
Re-vamp shutdown

8 years agoUpdate version in README (v0.03) v0.03
Davin McCall [Sun, 19 Jun 2016 16:00:12 +0000 (17:00 +0100)]
Update version in README (v0.03)

8 years agoAdd note that dinitctl isn't working on OpenBSD ATM.
Davin McCall [Sun, 19 Jun 2016 14:30:04 +0000 (15:30 +0100)]
Add note that dinitctl isn't working on OpenBSD ATM.

8 years agonext_for_console was not being set null when a service queued for
Davin McCall [Sun, 19 Jun 2016 14:16:10 +0000 (15:16 +0100)]
next_for_console was not being set null when a service queued for
the console (and was not initialised).

8 years agoUpdate README and TODO
Davin McCall [Sun, 19 Jun 2016 13:32:57 +0000 (14:32 +0100)]
Update README and TODO

8 years agoLarge refactoring of dinitctl.
Davin McCall [Sun, 19 Jun 2016 13:24:39 +0000 (14:24 +0100)]
Large refactoring of dinitctl.

8 years agoLog correct information regarding reason for process termination:
Davin McCall [Sat, 18 Jun 2016 22:29:37 +0000 (23:29 +0100)]
Log correct information regarding reason for process termination:
did it exit, was it signalled?

8 years agoDon't display "can't bind socket: read only file sytem" error on the
Davin McCall [Sat, 18 Jun 2016 19:37:14 +0000 (20:37 +0100)]
Don't display "can't bind socket: read only file sytem" error on the
first attempt to bind the control socket (immediately after starting).
It's pretty normal for the filesystem to be mounted read-only at that
stage.

8 years agoSeparate the commencement of logging and the opening of the control socket
Davin McCall [Sat, 18 Jun 2016 19:25:17 +0000 (20:25 +0100)]
Separate the commencement of logging and the opening of the control socket
into two distinct functions.

8 years agoAdd a new service setting, "options", which can be used for various options
Davin McCall [Sat, 18 Jun 2016 19:22:18 +0000 (20:22 +0100)]
Add a new service setting, "options", which can be used for various options
and which deprecates several other settings. Includes a new option, starts-log,
specifying that the service starts the syslog service.

8 years agoAdd a method to discard the console log buffer contents.
Davin McCall [Sat, 18 Jun 2016 19:21:06 +0000 (20:21 +0100)]
Add a method to discard the console log buffer contents.

8 years agoFix calculation of buffer size for LISTEN_FDS environment variable.
Davin McCall [Sat, 18 Jun 2016 17:05:01 +0000 (18:05 +0100)]
Fix calculation of buffer size for LISTEN_FDS environment variable.
(Fortunately, it still gave the correct result in all expected cases).

8 years agoSmall documentation updates.
Davin McCall [Sat, 18 Jun 2016 16:51:10 +0000 (17:51 +0100)]
Small documentation updates.

8 years agoUpdate Dasynq, again, and update Dinit code to reflect API changes.
Davin McCall [Sat, 18 Jun 2016 14:11:19 +0000 (15:11 +0100)]
Update Dasynq, again, and update Dinit code to reflect API changes.

Hopefully the Dasynq API is now fairly stable.

8 years agoYet another Dasynq update
Davin McCall [Thu, 16 Jun 2016 22:54:54 +0000 (23:54 +0100)]
Yet another Dasynq update

8 years agoPull in latest Dasynq, which means a massive amount of renaming.
Davin McCall [Thu, 16 Jun 2016 18:31:01 +0000 (19:31 +0100)]
Pull in latest Dasynq, which means a massive amount of renaming.

8 years agoUpdate TODO
Davin McCall [Thu, 16 Jun 2016 17:33:46 +0000 (18:33 +0100)]
Update TODO

8 years agoUpdate dasynq to latest HEAD
Davin McCall [Thu, 16 Jun 2016 07:27:22 +0000 (08:27 +0100)]
Update dasynq to latest HEAD

8 years agoUse the start queue instead of starting services immediately.
Davin McCall [Thu, 16 Jun 2016 07:26:09 +0000 (08:26 +0100)]
Use the start queue instead of starting services immediately.

8 years agoWrite log messages which cross the circular buffer boundary atomically,
Davin McCall [Wed, 15 Jun 2016 15:59:48 +0000 (16:59 +0100)]
Write log messages which cross the circular buffer boundary atomically,
using writev.

8 years agoIgnore SIGPIPE.
Davin McCall [Tue, 14 Jun 2016 22:02:40 +0000 (23:02 +0100)]
Ignore SIGPIPE.

8 years agoMake control socket handling safer and fix an inverted logic bug.
Davin McCall [Tue, 14 Jun 2016 22:01:22 +0000 (23:01 +0100)]
Make control socket handling safer and fix an inverted logic bug.
queuePacket() now no longer deletes the connection, meaning its
use the service listener is now safe.

8 years agoMissed processing start/stop queue in one place
Davin McCall [Tue, 14 Jun 2016 18:05:00 +0000 (19:05 +0100)]
Missed processing start/stop queue in one place

8 years agoIntroduce a "stop queue" and "start queue" in ServiceSet, to better
Davin McCall [Tue, 14 Jun 2016 17:05:31 +0000 (18:05 +0100)]
Introduce a "stop queue" and "start queue" in ServiceSet, to better
manage service interactions and avoid recursion. Both are implemented
as a singly-linked list of services. The queues are processed one
at a time until empty.

8 years agoUse _exit instead of exit after fork
Davin McCall [Tue, 14 Jun 2016 13:14:53 +0000 (14:14 +0100)]
Use _exit instead of exit after fork

8 years agoRework control protocol handling a little.
Davin McCall [Mon, 13 Jun 2016 21:21:08 +0000 (22:21 +0100)]
Rework control protocol handling a little.

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