Browse Source

Automated pm2 process spawn

Pitu 5 years ago
parent
commit
390eeb9b07
3 changed files with 32 additions and 9 deletions
  1. 3 6
      README.md
  2. 3 3
      docs/pm2.md
  3. 26 0
      pm2.json

+ 3 - 6
README.md

@@ -25,13 +25,10 @@ This guide asumes a lot of things, including that you know your way around linux
 Lolisafe is now installed, configured and ready. Now you need to serve it to the public by using a domain name.
 
 6. Check the [nginx](docs/nginx.md) file for a sample configuration that has every step to run lolisafe securely on production.
-7. After you finish setting up nginx, you need to start lolisafe by using pm2. If you want to use something else, figure out how. Run the following commands:
-```bash
-pm2 start npm --name "lolisafe.api" -- run api
-pm2 start npm --name "lolisafe.site" -- run site
-```
-(More info on why pm2 [here](docs/pm2.md))
 
+After you finish setting up nginx, you need to start lolisafe by using pm2. If you want to use something else, figure out how. (More info on why pm2 [here](docs/pm2.md))
+
+7. Run `pm2 start pm2.json`:
 8. Profit
 
 ### Cloudflare

+ 3 - 3
docs/pm2.md

@@ -4,8 +4,8 @@ The best way to keep the service running in case of crashes or unexpected issues
 The recommended way to set it up is to run the commands below, one for the API and the other for the site.
 
 ```
-pm2 start npm --name "lolisafe.api" -- run api
-pm2 start npm --name "lolisafe.site" -- run site
+pm2 start npm --name "lolisafe-api" -- run api
+pm2 start npm --name "lolisafe-site" -- run site
 ```
 
-All set, if you want to check the logs you can `pm2 logs lolisafe.api` or similar.
+All set, if you want to check the logs you can `pm2 logs lolisafe-api` or similar.

+ 26 - 0
pm2.json

@@ -0,0 +1,26 @@
+{
+	"apps" : [
+		{
+			"name": "lolisafe-api",
+			"script": "npm",
+			"args": "run api",
+			"env": {
+				"NODE_ENV": "production"
+			},
+			"env_production" : {
+				"NODE_ENV": "production"
+			}
+		},
+		{
+			"name": "lolisafe-website",
+			"script": "npm",
+			"args": "run site",
+			"env": {
+				"NODE_ENV": "production"
+			},
+			"env_production" : {
+				"NODE_ENV": "production"
+			}
+		}
+	]
+}