Running as a service
How raftdb-server install-service sets up a systemd unit or a Windows startup task, what the unit does, how to remove it, and what exists for raftdb-mysql and raftdb-watch.
raftdb-server install-service#
Syntax#
raftdb-server install-service [--profile NAME] [--config FILE] [--user NAME] [--no-start] [--print]
raftdb-server uninstall-serviceOptions#
| Option | Meaning | Default |
|---|---|---|
--profile NAME | The profile for a new settings file (single, primary, replica). | single |
--config FILE | Use this existing settings file instead of the standard one. | the standard file |
--user NAME | The system user the service runs as (Linux). | raftdb |
--no-start | Install only; do not start. | start |
--print | Show exactly what would be done, without doing it. Needs no administrator rights. | do it |
Linux (systemd)#
Run it as root (for example sudo raftdb-server install-service). It:
- Creates the system user
raftdb(no login). - Creates the data folder
/var/lib/raftdb(mode 750). - Creates
/etc/raftdb/raftdb.confonly if missing (mode 640, groupraftdb; frominit_textfor the profile). An existing file is never changed. - Copies the binary to
/usr/local/bin/raftdb-server. - Writes
/etc/systemd/system/raftdb.service, checks the settings (a new replica or primary file still has placeholders: it is installed but not started and says what to edit), enables and starts the service, waits until the port answers and prints the address andsudo cat /var/lib/raftdb/admin.password.
The unit restarts on failure and is sandboxed: no capabilities, no new privileges, the file system read-only except the data folder, no devices or kernel settings, only IP and Unix sockets, no writable-and-executable memory. systemd-analyze security rated the first version 8.3 (EXPOSED) and the current one 3.0 (OK) (D45).
Manage it with the usual commands:
sudo systemctl status raftdb
sudo journalctl -u raftdb
sudo systemctl restart raftdbWindows#
The same command registers a startup task named Raft DB Server in Task Scheduler (runs as SYSTEM at boot) with the files in %ProgramData%\RaftDB. It is a startup task and not a Windows service, because a real service must speak the Service Control Manager protocol and that needs foreign calls the engine does not have. The decision (D45) says to revisit it if a customer needs a true service. It is not documented whether the task restarts the server after a crash; run raftdb-watch with a restart_command that restarts it if you need that.
Uninstall#
raftdb-server uninstall-service removes the unit or task. Data and settings stay.
Not done#
Packages (deb, rpm, MSI), a true Windows service, and the watcher reading raftdb.conf.
raftdb-mysql and raftdb-watch#
install-service installs only raftdb-server. For the others:
| Program | What exists |
|---|---|
raftdb-watch | An example unit for it (Restart=always, a raftdbwatch user) and an example raftdb.service for a server it watches (--dir /var/lib/raftdb --addr 0.0.0.0:7480 --udp --user admin:CHANGE-ME --user watcher:CHANGE-ME-TOO:readwrite, Restart=on-failure, LimitNOFILE=65536). Edit both: the example passes passwords on the command line, which show in the process list. |
raftdb-mysql | Nothing. A unit of the same shape as raftdb.service that runs raftdb-mysql --config /etc/raftdb/mysql.conf works the same way, but none is shipped or tested. With embed, raftdb-mysql is the server process: do not also run raftdb-server on the embedded raftdb.conf. |
If you run raftdb-mysql with embed, then it is the process to put under the service manager, and the raftdb-server install-service unit is not used (the two would fight over the data directory).
Checklist#
- A system user that owns only the data directory.
- Settings in a file, not in the unit's command line, so passwords stay out of the process list.
- The watcher's
restart_commandmatches how you start the process. - A raised open-files limit if you expect many connections (the example sets
LimitNOFILE=65536); each connection uses two threads.