# 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`:

```bash
[Unit]
Description=My Application
After=network.target

[Service]
WorkingDirectory=/home/ubuntu/flask/
User=ubuntu
ExecStart=/home/ubuntu/miniconda3/envs/myenv/bin/python /home/ubuntu/flask/app.py
Restart=always

[Install]
WantedBy=multi-user.target
```

2\. Reload systemd to recognize the new service:

```bash
sudo systemctl daemon-reload
```

3\. Start and enable the service:

```bash
sudo systemctl start myapp
sudo systemctl enable myapp
```

4\. Check status

```bash
sudo systemctl status myapp
```

Example O/P:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1710134057608/c01ac9e7-958d-4dc8-8bef-8b507cd4f115.png align="center")

**Conclusion:**

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