Tangent128 / sema

Lua-based daemon supervisor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sema

A Lua-scripted daemon management service.

What is Sema?

sema is a service manager written in Lua and C.

It is designed to serve the same general role as initd, upstart or systemd, while drawing additional inspiration from daemontools and runit.

A sema server daemon supervises multiple services under the direction of Lua scripts, which can receive custom commands from client commands. A client can also auto-spawn a server if none is currently running.

The project's git repository and bug tracker may be found at https://github.com/Tangent128/sema

Usage

sema --server

Launch a foreground server process, which can receive commands from future clients.

sema --client scriptFile.sema [command [args...]]

Connect to the server and ensure the script 'scriptFile.sema' is running; optionally send command and arguments to the script.

sema scriptFile.sema [command [args...]]

Like --client, but automatically spawn a background server if a server is not yet running.

sema --ls

List the server's currently loaded scripts, and PIDs of any daemons.

sema --kill scriptFile.sema

Force-quit a script on the server and SIGKILL its daemons.

Scripts

A simple sema script for supervising and controlling SSHD:

#!/path/to/sema
-- The above shabang line is useful if you mark your control scripts executable

-- define a custom command
function command.reloadConfig()
	signal(nil, SIGHUP)
end

-- "up" and "down" have default implementations

while true do
	runIfUp{
		cmd "/usr/sbin/sshd -D"
	}
end

For fuller documentation of the script API, see SCRIPTING.md and the files under example/

Environment

The control socket for the client and server to use may be specified by the $SEMA_SOCKET environment variable.

Otherwise, the default socket location depends on the current user; if running as root, then /run/sema.socket will be used.

If running as an ordinary user, $XDG_RUNTIME_DIR/sema.socket and $HOME/.sema.socket will be tried, in that order.

Building

sema uses the [Redo] build system; however, installing redo is not necessary, as a minimal always-rebuilds implementation is included under redo/do.sh. [Redo]: https://github.com/apenwarr/redo

Building requires a libc and your distribution's basic build tools. (ie, 'build-essential' on Debian)

From the root of the repository, run:

redo/do.sh sema

or

redo sema

as appropriate; the resulting "sema" executable may be installed where desired.

If not using GCC: CC & LD variables may be set in a file named config, with standard shell syntax.

To use a distribution version of Lua 5.2 instead of the bundled source, add a useInstalledLua statement to the config file.

License

sema is MIT-licensed, like Lua.

For the full license read COPYRIGHT.md.

About

Lua-based daemon supervisor

License:Other


Languages

Language:C 91.1%Language:Lua 5.9%Language:C++ 1.5%Language:Shell 1.2%Language:CSS 0.3%