Runit
How the runit process supervisor manages applications on your serverlet.
Runit manages all applications on the serverlet. It makes sure all applications start when the serverlet boots and are restarted automatically if they crash. All of its configuration lives in the /srv/service directory β right after your serverlet is created, youβll find folders for each background service and their startup scripts there.
Adding your own application
Adding your own application is very simple. Once added, you can also control it from Administration.
Steps to add an application:
-
First, create a directory named after your application inside
/srv/service. For example:/srv/service/moje-aplikace -
Then create a
runfile inside that directory to start the application. In our example:/srv/service/moje-aplikace/run -
In that file, you need to specify the command to start the desired application. The application itself must keep its main process running in the foreground rather than daemonizing. Otherwise, it would cause repeated restart attempts that consume most of the serverletβs resources β for some applications, youβll need to disable daemon mode.
Example run file for MongoDB:
#!/bin/sh -ee
exec 2>&1
exec /usr/bin/mongod --config /srv/config/mongodb/mongod.conf-
Save the file. The
appletuser must have all the necessary permissions on the folder for runit to work correctly. -
Runit will detect and start the newly added application within a few dozen seconds on its own. It stores information it needs, such as the process PID, in a
supervisesubdirectory. -
Thatβs it! Your application will now start automatically on boot and restart if it crashes. You can control your application using the
apporsvcommand β see Serverlet Control.
You can find more useful information on the runit website.
Removing an application
Removing an application is very simple. Just stop it with app stop {moje-aplikace} and then delete its folder in /srv/service.
Mishandling the
/srv/servicedirectory and the configuration of pre-installed applications can break them.
Last updated
