Alternative PM2 / Run Flask without PM2

Alternative PM2 / Run Flask without PM2

systemd is a system and service manager for Linux operating systems. It is designed to manage the system and its services, including starting and stopping services, managing dependencies, and monitoring system processes.

to run using PM2, we need NodeJS and NPM.

But systemd doesn't require any.

1. Create a service file, for example, /etc/systemd/system/myapp.service:

Description=My Application

ExecStart=/home/ubuntu/miniconda3/envs/myenv/bin/python /home/ubuntu/flask/


2. Reload systemd to recognize the new service:

sudo systemctl daemon-reload

3. Start and enable the service:

sudo systemctl start myapp
sudo systemctl enable myapp

4. Check status

sudo systemctl status myapp

Example O/P:


Don't install unnecessary packages; instead, use systemd.