Skip to content

Systemd

Systemd is a common process management service that comes preinstalled in systems like RHEL7+, Ubuntu, etc. This makes it easy to use as no additional installation is required and can be used with minimal effort and some additional configurations.

Warning

If systemd is not preinstalled and another process-management tool like init.d or others are available, it is recommended to use that rather than installing systemd. Installing multiple system-level process-management tools can cause issues.

Configurations

Once installed, the supervisor configuration needs to be created per process that needs to be managed.

To set-up the configurations, the following steps need to be followed:

  • Add service file to systemd services folder. For example: /etc/systemd/system/corridor.service
  • To start service: sudo systemctl start corridor
    And to run the service on startup: sudo systemctl enable corridor

Here are some example configuration files for the Corridor components:

Web Application server:

[Unit]
Description=Corridor Web Application
After=syslog.target network.target

[Service]
User=root
ExecStart=/bin/bash -c 'INSTALL_DIR/venv-app/bin/corridor-app run \
  >> /var/log/corridor/corridor-app.log 2>&1'
Restart=always

[Install]
WantedBy=multi-user.target

API server:

[Unit]
Description=Corridor API
After=syslog.target network.target

[Service]
User=root
ExecStart=/bin/bash -c 'INSTALL_DIR/venv-api/bin/corridor-api run \
  >> /var/log/corridor/corridor-api.log 2>&1'
Restart=always

[Install]
WantedBy=multi-user.target

API - Celery worker:

[Unit]
Description=Corridor Worker API
After=syslog.target network.target

[Service]
User=root
ExecStart=/bin/bash -c 'INSTALL_DIR/venv-api/bin/corridor-worker run --queue api \
  >> /var/log/corridor/corridor-worker-api.log 2>&1'
Restart=always

[Install]
WantedBy=multi-user.target

Spark - Celery worker:

[Unit]
Description=Corridor Worker Spark
After=syslog.target network.target

[Service]
User=root
ExecStart=/bin/bash -c 'INSTALL_DIR/venv-api/bin/corridor-worker run --queue spark --queue quick_spark \
  >> /var/log/corridor/corridor-worker-spark.log 2>&1'
Restart=always

[Install]
WantedBy=multi-user.target

Jupyter Notebook:

[Unit]
Description=Corridor Jupyter
After=syslog.target network.target

[Service]
User=root
ExecStart=/bin/bash -c 'INSTALL_DIR/venv-api/bin/corridor-jupyter run \
  >> /var/log/corridor/corridor-jupyter.log 2>&1'
Restart=always

[Install]
WantedBy=multi-user.target