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:

  1. First, create a directory named after your application inside /srv/service. For example: /srv/service/moje-aplikace

  2. Then create a run file inside that directory to start the application. In our example: /srv/service/moje-aplikace/run

  3. 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:

plaintext
#!/bin/sh -ee
exec 2>&1
exec /usr/bin/mongod --config /srv/config/mongodb/mongod.conf
  1. Save the file. The applet user must have all the necessary permissions on the folder for runit to work correctly.

  2. 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 supervise subdirectory.

  3. That’s it! Your application will now start automatically on boot and restart if it crashes. You can control your application using the app or sv command β€” 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/service directory and the configuration of pre-installed applications can break them.

Last updated