An open API service indexing awesome lists of open source software.

https://github.com/cloudhead/spinsv

a stateless service runner inspired by runit
https://github.com/cloudhead/spinsv

Last synced: 11 months ago
JSON representation

a stateless service runner inspired by runit

Awesome Lists containing this project

README

          

SPINSV

A service runner inspired by runsv.

. background

A common need encountered when running services on a unix system is
to pipe the output of one service into the input of another, (often
a log service such as `svlogd`). This looks something like this:

#!/bin/sh

service | log-service

There are several problems with this approach, however:

* There is no monitoring: if either of the services die,
they aren't restarted.
* It's hard to inspect the state of the process pair,
especially if it goes down.
* Even if the script is restarted when either of the services
fails, this means the log service will cause a restart of the
other service if it dies.
* There is no single entry point to managing the process pair.

spinsv aims to solve these shortcomings by monitoring the processes
and providing a TCP console to access or change the process state.

. rationale

To have a completely stateless[1] service runner configurable via
the command line.

1. spinsv doesn't need file system access for configuration
or operation.

. building

$ make

. running

$ spind --port 80

For spinsv, see 'spinsv --help'

. example

Start the spind daemon on a remote host

$ ssh 10.0.1.32
$ spinsv --in.cmd spind \
--in.arg '--port=80' \
--out.cmd svlogd \
--out.arg /var/run/spind

Spawn a service via spind's HTTP interface. spinsv will open
a TCP control socket on port 9898.

$ curl -X POST 10.0.1.32/jobs -d \
'{"service": {"cmd": "redis-server", "args": []},
"logger": {"cmd": "svlogd", "args": ["/var/run/redis/log"]},
"port": 9898}'

The service runs under spinsv, we can verify that it is running:

$ netcat 10.0.1.32 9898
> status
up 0 0
> q

$ redis-cli -h 10.0.1.32 info
redis_version:2.6.11
...

. copyright

(C) 2012 Alexis Sellier