Skip to content

Commit

Permalink
Added documentation for PM2.
Browse files Browse the repository at this point in the history
  • Loading branch information
rizen committed Sep 6, 2024
1 parent 5919bcf commit 2f28602
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions ving/docs/.vitepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default defineConfig({
{ text: 'Jobs', link: '/subsystems/jobs' },
{ text: 'Logging', link: '/subsystems/logging' },
{ text: 'Message Bus', link: '/subsystems/messagebus' },
{ text: 'PM2', link: '/subsystems/pm2' },
{ text: 'Rest', link: '/subsystems/rest' },
{ text: 'Social Integration', link: '/subsystems/social' },
{ text: 'UI', link: '/subsystems/ui' },
Expand Down
5 changes: 5 additions & 0 deletions ving/docs/change-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ outline: deep
# Change Log

## September 2024

### 2024-09-06
* Added documentation for PM2.

### 2024-09-01
* Created process.json for PM2.

## August 2024
Expand Down
51 changes: 51 additions & 0 deletions ving/docs/subsystems/pm2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
outline: deep
---
# PM2
[PM2 or Node Process Manager 2](https://github.com/Unitech/pm2) is a framework for managing long-running processes. We use it to manage the Ving web and jobs servers in production.

## Setup

### Install
Install PM2 globally on your server like so:

```bash
npm i -g pm2
```

### Make a Process File
There is a file called `process.json` in the root of your project. Copy that file to match the name of whatever processes you need it to run for the specific environment you're targeting. For example, it could be `prod.json` or `qa-process.json`. It's up to you.

### Edit the Process File
The process file has rules for what processes should be run, and how they should be managed. `process.json` has sane defaults, but you can change them to your liking.

By default it will run 1 nuxt process per CPU core of your server, plus 2 job workers. [Click here](https://pm2.keymetrics.io/docs/usage/application-declaration/) for more information on how to configure PM2.

## Using PM2

*Note:* To use PM2 you need to be in the root folder of your project.

### Start the Processes

```bash
pm2 start process.json
```

### Stop the Processes

```bash
pm2 stop all
```

### View the Processes

```bash
pm2 monit
```

### More Commands

```bash
pm2 --help
pm2 [command] --help
```

0 comments on commit 2f28602

Please sign in to comment.