https://github.com/spcomb/netdaemon
[Archive] Prototype container init / service manager daemon (2009)
https://github.com/spcomb/netdaemon
Last synced: 10 months ago
JSON representation
[Archive] Prototype container init / service manager daemon (2009)
- Host: GitHub
- URL: https://github.com/spcomb/netdaemon
- Owner: SpComb
- Created: 2017-10-25T09:29:28.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-25T09:40:33.000Z (over 8 years ago)
- Last Synced: 2025-08-05T05:56:21.459Z (10 months ago)
- Language: C
- Size: 388 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
Awesome Lists containing this project
README
*** netdaemon ***
Remote control of persistent processes.
** About *
netdaemon is a daemon program that offers an remote/asynchronous API for running and controlling a set of other
processes. Also included is a client library and command-line utility.
The daemon runs a set of background processes, and clients may connect to the daemon (over an UNIX socket) and attach
to a process to control it. Clients can also query the list of available processes and start new ones. The daemon
offers control over:
* exec path
* exec arguments
* exec environment
* sending signals
* watching status (exit, kill)
* sending data/EOF to stdin
* recieving data/EOF from stdout/stderr
** Operation **
Each connection to the daemon undergoes protocol handshake before proceeding to actual operation.
In operational mode, the client can:
* query the listing of active processes (CMD_LIST)
* attach to a running process (CMD_ATTACH)
* perform operations on the attached process and recieve operational status
* recieve notification of exit/signal-terminate (CMD_STATUS)
* send data/eof to stdin (CMD_DATA)
* recieve data/eof from stdout/stderr (CMD_DATA)
* send signals (CMD_KILL)
* start a new process and attach to it (CMD_START)
Each client connection can, at most, be attached to one process at a time.
Each process initiated has an unique ID handle associated with it, which can be used by the clients to identify and
attach to a process after starting one and reconnecting.
** Compiling **
The code has been developed on Ubuntu Linux 2.6.24/28 using GCC 4.2.4/4.3.3.
It uses GNU-specific extensions to the C language, and hence compiles with -std=gnu99 and uses _GNU_SOURCE in places.
The code compiles without warnings apart from passing non-void* to printf-%p.
make
** Examples **
0$ ./bin/daemon -v -u run/netdaemon
1$ ./bin/client -q -u run/netdaemon start -- /usr/bin/wc -l
foo
bar
^C
1$ ./bin/client -u run/netdaemon list
> ... process_id=/usr/bin/wc:31299, status=1:31299
1$ ./bin/client -u run/netdaemon attach /usr/bin/wc:31299
^D
> 2
1$ ./bin/client -u run/netdaemon start -- /bin/cat
> ... Attached to process: /bin/cat:31464
foo
> foo
2$ ./bin/client -u run/netdaemon kill /bin/cat:31464 15
1$
> Terminated
** Bugs **
Sometimes, the client will disconnect as soon as the process exits, but before it recieves all stdout/err output.
** TODO **
* proto: also transmit stdin/out/err EOF-state in CMD_ATTACHED/CMD_STATUS, so the client doesn't try and feed
input to a closed stdin
* daemon: resolve behaviour of select_loop_del as regards calling from within select_loop_run
* client: ordering of on_exit/on_stdout/stderr-eof to only exit once process has exited AND we have EOF on both
* client: better display of process status