Process Management
For ease of maintenance and monitoring, it is recommended to use a process management tool to ensure the component daemons are running correctly. Using a process manager can simplify restarts, reboots, status-checks, logging, and configurations.
The process management tools that are frequently used are Systemd, init-script, etc. In general, it is recommended to use the tool that the OS provides to handle these tasks.
To simplify the installation, Supervisor can also be used, which provides application-level process management that is independent of the host setup.
The tools available for process management require sudo access which might not be an option in some situations.
Corridor has its own process manager for each of the components, which uses daemonisation to handle long-running,
background processes.
Daemon Mode
Section titled “Daemon Mode”No additional configurations are required when running Corridor processes using Corridor-Daemons. We can use the below set of commands to start/stop/check_status. The logfile and pidfile for each process can be saved at custom locations by using the parameters:
- logfile: location of the log file
- pidfile: location of the pid file
The default logfile directory is: INSTALL_DIR/instances/INSTANCE/logs
The default pidfile directory is: INSTALL_DIR/instances/INSTANCE/pids
To start the processes, we can do:
INSTALL_DIR/venv-api/corridor-api daemon startINSTALL_DIR/venv-api/corridor-worker daemon startINSTALL_DIR/venv-app/corridor-app daemon startINSTALL_DIR/venv-jupyter/corridor-jupyter daemon startTo stop the processes, we can do:
INSTALL_DIR/venv-api/corridor-api daemon stopINSTALL_DIR/venv-api/corridor-worker daemon stopINSTALL_DIR/venv-app/corridor-app daemon stopINSTALL_DIR/venv-jupyter/corridor-jupyter daemon stopTo check the status of the processes, we can do:
INSTALL_DIR/venv-api/corridor-api daemon statusINSTALL_DIR/venv-api/corridor-worker daemon statusINSTALL_DIR/venv-app/corridor-app daemon statusINSTALL_DIR/venv-jupyter/corridor-jupyter daemon statusSupervisor
Section titled “Supervisor”To use corridor with Supervisor, some useful configurations are:
command: The command to execute. Note, if 2 commands need to be executed, usebash -c "command1; command2"stdout_logfile: Log file location for the stdout logs (%(program_name)sand%(process_num)01dcan be used as variables)stderr_logfileorredirect_stderr: Log file location for the stderr logs, or redirect all the stderr logs to the stdout stream and hence have a common file for bothuser: The user to run the process asenvironment: The environment variables to be set before the process is runnumprocs: The number of processes to run
Here are some example configuration files for the Corridor components:
Web Application server:
[program:corridor-app]command=INSTALL_DIR/venv-app/bin/corridor-app runstdout_logfile=/var/log/corridor/%(program_name)s.logredirect_stderr=trueuser=rootAPI server:
[program:corridor-api]command= bash -c "INSTALL_DIR/venv-api/bin/corridor-api db upgrade && INSTALL_DIR/venv-api/bin/corridor-api run"stdout_logfile=/var/log/corridor/%(program_name)s.logredirect_stderr=trueuser=rootAPI - Celery worker:
[program:corridor-worker-api]command=INSTALL_DIR/venv-api/bin/corridor-worker run --queue apienvironment= C_FORCE_ROOT=1stdout_logfile=/var/log/corridor/%(program_name)s.logredirect_stderr=trueuser=rootSpark - Celery worker:
[program:corridor-worker-spark]command=INSTALL_DIR/venv-api/bin/corridor-worker run --queue spark --queue quick_sparkenvironment= C_FORCE_ROOT=1stdout_logfile=/var/log/corridor/%(program_name)s.logredirect_stderr=trueuser=rootJupyter Notebook:
[program:corridor-jupyter]command=INSTALL_DIR/venv-jupyter/bin/corridor-jupyter runstdout_logfile=/var/log/corridor/%(program_name)s.logredirect_stderr=trueuser=rootSystemd
Section titled “Systemd”Many Linux OS like RHEL have systemd pre-installed. To use systemd, 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 ApplicationAfter=syslog.target network.target
[Service]User=rootExecStart=/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.targetAPI server:
[Unit]Description=Corridor APIAfter=syslog.target network.target
[Service]User=rootExecStart=/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.targetAPI - Celery worker:
[Unit]Description=Corridor Worker APIAfter=syslog.target network.target
[Service]User=rootExecStart=/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.targetSpark - Celery worker:
[Unit]Description=Corridor Worker SparkAfter=syslog.target network.target
[Service]User=rootExecStart=/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.targetJupyter Notebook:
[Unit]Description=Corridor JupyterAfter=syslog.target network.target
[Service]User=rootExecStart=/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