# Process Managers

{% hint style="danger" %}
This documentation site is deprecated. Please visit the README of <https://github.com/synzen/MonitoRSS> for hosting instructions.
{% endhint %}

Optionally use a process manager to keep the process running in the background (make sure you manually run it after setting up to resolve any issues *before* doing this):

* [Process Manager 2 (pm2)](https://www.npmjs.com/package/pm2)
* [forever](https://www.npmjs.com/package/forever)
* systemd
* Whatever other process manager you want

{% hint style="danger" %}
Be wary of your process manager(s) doing infinite restarts. This may lead to you being blocked or banned by Discord.
{% endhint %}

## PM2 / Forever

1. `npm install -g pm2` or `npm install -g forever` in terminal.
   * add `sudo` before npm if you have permission issues.
2. `cd MonitoRSS` assuming your folder is named MonitoRSS
3. `pm2 start bot.js` or `forever start bot.js`

### Realtime Log Tracking

1. Use `pm2 list` or `forever list` to show the process ID.
2. `pm2 logs processID` or `forever logs processID -f` - you'll now be shown a short recent history of the bot logs, and any further

### Complete History/Logs of Bot

1. Use `pm2 show processID`/`forever list` to show the `out log path`/`logfile` location.
2. `cat /my/location/<log name>.log`. This is not realtime tracking.

### Clearing History

1. `pm2 flush`/`forever cleanlogs`

### Stopping the Bot

1. `pm2 stop processID`/`forever stop processID`

### Restarting

1. `pm2 restart processID`/`forever restart processID`

## systemd

(credited to [Danpiel](https://github.com/synzen/Discord.RSS/issues/4))

1. Create unit file in `/etc/systemd/system/discord-rss.service` with contents

```
[Unit]
Description=Discord RSS bot

[Service]
WorkingDirectory=/opt/discord-rss/
ExecStart=/usr/bin/node /opt/discord-rss/server.js
Type=simple
Restart=on-failure
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=discord-rss

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

1. Reload systemd to take new configuration `sudo systemctl daemon-reload`
2. Start it with `sudo systemctl start discord-rss`
3. Enable autostart with `sudo systemctl enable discord-rss`
4. Logs can be checked with `sudo journalctl -fu discord-rss`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.monitorss.xyz/setting-up/process-managers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
