---
title: Runit
description: 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](https://old-app.futrou.com).

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:

```
#!/bin/sh -ee
exec 2>&1
exec /usr/bin/mongod --config /srv/config/mongodb/mongod.conf
```

4. Save the file. The `applet` user must have all the necessary permissions on the folder for runit to work correctly.

5. 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.

6. 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](/docs/serverlet/control/).

You can find more useful information on the runit [website](http://smarden.org/runit/).

## 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.