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)
Davin McCall [Sun, 19 Jun 2016 16:44:05 +0000 (17:44 +0100)]
Re-vamp shutdown
Davin McCall [Sun, 19 Jun 2016 16:00:12 +0000 (17:00 +0100)]
Update version in README (v0.03)
Davin McCall [Sun, 19 Jun 2016 14:30:04 +0000 (15:30 +0100)]
Add note that dinitctl isn't working on OpenBSD ATM.
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).
Davin McCall [Sun, 19 Jun 2016 13:32:57 +0000 (14:32 +0100)]
Update README and TODO
Davin McCall [Sun, 19 Jun 2016 13:24:39 +0000 (14:24 +0100)]
Large refactoring of dinitctl.
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?
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.
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.
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.
Davin McCall [Sat, 18 Jun 2016 19:21:06 +0000 (20:21 +0100)]
Add a method to discard the console log buffer contents.
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).
Davin McCall [Sat, 18 Jun 2016 16:51:10 +0000 (17:51 +0100)]
Small documentation updates.
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.
Davin McCall [Thu, 16 Jun 2016 22:54:54 +0000 (23:54 +0100)]
Yet another Dasynq update
Davin McCall [Thu, 16 Jun 2016 18:31:01 +0000 (19:31 +0100)]
Pull in latest Dasynq, which means a massive amount of renaming.
Davin McCall [Thu, 16 Jun 2016 17:33:46 +0000 (18:33 +0100)]
Update TODO
Davin McCall [Thu, 16 Jun 2016 07:27:22 +0000 (08:27 +0100)]
Update dasynq to latest HEAD
Davin McCall [Thu, 16 Jun 2016 07:26:09 +0000 (08:26 +0100)]
Use the start queue instead of starting services immediately.
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.
Davin McCall [Tue, 14 Jun 2016 22:02:40 +0000 (23:02 +0100)]
Ignore SIGPIPE.
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.
Davin McCall [Tue, 14 Jun 2016 18:05:00 +0000 (19:05 +0100)]
Missed processing start/stop queue in one place
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.
Davin McCall [Tue, 14 Jun 2016 13:14:53 +0000 (14:14 +0100)]
Use _exit instead of exit after fork
Davin McCall [Mon, 13 Jun 2016 21:21:08 +0000 (22:21 +0100)]
Rework control protocol handling a little.
Davin McCall [Mon, 13 Jun 2016 21:20:28 +0000 (22:20 +0100)]
Update dasynq
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...
Davin McCall [Sun, 12 Jun 2016 23:57:20 +0000 (00:57 +0100)]
Update dasynq
Davin McCall [Sun, 12 Jun 2016 23:21:09 +0000 (00:21 +0100)]
Catch a broader range of exceptions when creating a ControlConn
Davin McCall [Sun, 12 Jun 2016 23:18:57 +0000 (00:18 +0100)]
Fix condition for detecting read failure in process_child_status().
Davin McCall [Sun, 12 Jun 2016 09:06:01 +0000 (10:06 +0100)]
Implement DINIT_CP_RELEASESERVICE command.
Davin McCall [Sun, 12 Jun 2016 09:00:49 +0000 (10:00 +0100)]
Code consistency and documentation update
Davin McCall [Sat, 11 Jun 2016 20:21:25 +0000 (21:21 +0100)]
Map dinit-log log levels to syslog log levels
Davin McCall [Sat, 11 Jun 2016 19:38:22 +0000 (20:38 +0100)]
Enable logging to syslog.
Davin McCall [Sat, 11 Jun 2016 18:24:02 +0000 (19:24 +0100)]
Incorporate latest bugfixes from dasynq
Davin McCall [Sat, 11 Jun 2016 14:59:46 +0000 (15:59 +0100)]
Fix (remove) noexcept specification for init_log().
Davin McCall [Sat, 11 Jun 2016 14:55:46 +0000 (15:55 +0100)]
Full support within the logging subsystem to an external source (fd).
Davin McCall [Sat, 11 Jun 2016 10:51:14 +0000 (11:51 +0100)]
More refactoring in preparation for proper logging support
Davin McCall [Sat, 11 Jun 2016 10:06:54 +0000 (11:06 +0100)]
Minor refactoring
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.
Davin McCall [Mon, 6 Jun 2016 23:30:20 +0000 (00:30 +0100)]
TODO updates.
Davin McCall [Mon, 6 Jun 2016 22:40:51 +0000 (23:40 +0100)]
Whitespace fixes
Davin McCall [Mon, 6 Jun 2016 22:12:18 +0000 (23:12 +0100)]
No need to link libev anymore.
Davin McCall [Mon, 6 Jun 2016 22:11:49 +0000 (23:11 +0100)]
Refactoring, and actually enable console log in enable_console_log()...
Davin McCall [Mon, 6 Jun 2016 19:40:39 +0000 (20:40 +0100)]
Remove obseleted TODO comment
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.
Davin McCall [Mon, 6 Jun 2016 18:11:18 +0000 (19:11 +0100)]
Update dasynq
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.
Davin McCall [Mon, 6 Jun 2016 07:31:48 +0000 (08:31 +0100)]
Suppress "invalid offsetof" warnings.
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).
Davin McCall [Sun, 5 Jun 2016 20:25:53 +0000 (21:25 +0100)]
Fix condition in is_log_flushed
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.
Davin McCall [Sun, 5 Jun 2016 18:31:15 +0000 (19:31 +0100)]
Refactorings.
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...
Davin McCall [Sun, 5 Jun 2016 14:32:48 +0000 (15:32 +0100)]
OpenBSD: use __thrsigdivert as a replacement for sigtimedwait.
Davin McCall [Sun, 5 Jun 2016 09:31:00 +0000 (10:31 +0100)]
Make selection of epoll/kqueue backend automatic
Davin McCall [Sun, 5 Jun 2016 02:29:12 +0000 (03:29 +0100)]
Beginnings of kqueue support (far from complete)
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).
Davin McCall [Tue, 19 Jan 2016 19:13:18 +0000 (19:13 +0000)]
Refactoring. Move buffered output management (variables) into a
class.
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).
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).
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").
Davin McCall [Sat, 16 Jan 2016 13:47:08 +0000 (13:47 +0000)]
Add/correct some comments
Davin McCall [Sat, 16 Jan 2016 12:54:05 +0000 (12:54 +0000)]
Make CPBuffer a template, parameterized by buffer size
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.
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).
Davin McCall [Thu, 14 Jan 2016 18:19:41 +0000 (18:19 +0000)]
Remove some explicit memory deallocation in favor of using unique_ptr.
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...)
Davin McCall [Thu, 14 Jan 2016 10:02:06 +0000 (10:02 +0000)]
Remove std::move(...) so that copy ellision can occur.
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)
Davin McCall [Wed, 13 Jan 2016 18:51:10 +0000 (18:51 +0000)]
Add support for pinning services to dinitctl
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.
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)
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).
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.
Davin McCall [Mon, 11 Jan 2016 23:56:04 +0000 (23:56 +0000)]
Various changes to match changes to command protocol.
Davin McCall [Mon, 11 Jan 2016 23:52:36 +0000 (23:52 +0000)]
Refactor/fix control commands, add a few start/stop alternatives
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).
Davin McCall [Mon, 11 Jan 2016 22:59:24 +0000 (22:59 +0000)]
Make sure to initialise all members of ControlConn
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.
Davin McCall [Mon, 11 Jan 2016 20:00:40 +0000 (20:00 +0000)]
Cleanups and refactoring.
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.
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.
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.
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.
Davin McCall [Thu, 7 Jan 2016 23:06:54 +0000 (23:06 +0000)]
Fix protocol errors in dinitctl
Davin McCall [Thu, 7 Jan 2016 22:08:40 +0000 (22:08 +0000)]
Add license (Apache license version 2.0).
Davin McCall [Thu, 7 Jan 2016 22:08:10 +0000 (22:08 +0000)]
Update gitignore
Davin McCall [Thu, 7 Jan 2016 22:02:05 +0000 (22:02 +0000)]
Make sure to not write a partial command packet.
Davin McCall [Thu, 7 Jan 2016 21:34:23 +0000 (21:34 +0000)]
dinitctl: recognize and report FAILEDSTART events.
Davin McCall [Thu, 7 Jan 2016 20:45:09 +0000 (20:45 +0000)]
Refactoring: remove unneeded method
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...
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.
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.
Davin McCall [Tue, 5 Jan 2016 23:55:05 +0000 (23:55 +0000)]
Move source files int src directory
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.
Davin McCall [Mon, 4 Jan 2016 00:13:06 +0000 (00:13 +0000)]
Update TODO list
Davin McCall [Mon, 4 Jan 2016 00:01:43 +0000 (00:01 +0000)]
Implement socket activation (single, unix-family socket only)