forked from Unitech/pm2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add example with dotenvx to reproduce Unitech#3192 --update-env…
… bug
- Loading branch information
Showing
5 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
DE=dotenv | ||
SH_DE=dotenv | ||
DE_PM=dotenv | ||
SH_DE_PM=dotenv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
To start http application in cluster mode: | ||
|
||
```bash | ||
$ pm2 start ecosystem.config.js | ||
# OR | ||
$ pm2 start http.js -i max | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module.exports = { | ||
apps: [ | ||
{ | ||
name: 'forked_app', | ||
script: './index.js', | ||
env: { | ||
PORT: 8001, | ||
PM: 'pm2', | ||
SH_PM: 'pm2', | ||
DE_PM: 'pm2', | ||
SH_DE_PM: 'pm2', | ||
}, | ||
}, | ||
{ | ||
name: 'clustered_app', | ||
script: './index.js', | ||
instances: 2, | ||
exec_mode: 'cluster', | ||
env: { | ||
PORT: 8002, | ||
PM: 'pm2', | ||
SH_PM: 'pm2', | ||
DE_PM: 'pm2', | ||
SH_DE_PM: 'pm2', | ||
}, | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import http from 'http'; | ||
|
||
const { | ||
PORT, | ||
SH, | ||
DE, | ||
PM, | ||
SH_DE, | ||
SH_PM, | ||
DE_PM, | ||
SH_DE_PM, | ||
} = process.env; | ||
|
||
http.createServer((req, res) => { | ||
res.writeHead(200); | ||
res.end(JSON.stringify({ | ||
SH, | ||
DE, | ||
PM, | ||
SH_DE, | ||
SH_PM, | ||
DE_PM, | ||
SH_DE_PM, | ||
}, null, 2)); | ||
}).listen(PORT, '0.0.0.0', () => { | ||
console.log(`App listening on port ${PORT}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "dotenvx-pm2", | ||
"version": "1.0.0", | ||
"description": "Example usage of dotenvx with pm2", | ||
"main": "index.js", | ||
"type": "module", | ||
"author": "Michael Kalygin", | ||
"license": "MIT", | ||
"scripts": { | ||
"start:json:simple": "SH=shell SH_DE=shell SH_PM=shell SH_DE_PM=shell dotenvx run --env-file .env -- ../../bin/pm2 start ecosystem.config.cjs", | ||
"start:json:overload": "SH=shell SH_DE=shell SH_PM=shell SH_DE_PM=shell dotenvx run --env-file .env --overload -- ../../bin/pm2 start ecosystem.config.cjs", | ||
"start:pid:simple": "SH=shell SH_DE=shell SH_PM=shell SH_DE_PM=shell dotenvx run --env-file .env -- ../../bin/pm2 start forked_app clustered_app", | ||
"start:pid:overload": "SH=shell SH_DE=shell SH_PM=shell SH_DE_PM=shell dotenvx run --env-file .env --overload -- ../../bin/pm2 start forked_app clustered_app", | ||
"reload:json:simple": "SH=shell SH_DE=shell SH_PM=shell SH_DE_PM=shell dotenvx run --env-file .env -- ../../bin/pm2 reload ecosystem.config.cjs --update-env", | ||
"reload:json:overload": "SH=shell SH_DE=shell SH_PM=shell SH_DE_PM=shell dotenvx run --env-file .env --overload -- ../../bin/pm2 reload ecosystem.config.cjs --update-env", | ||
"reload:pid:simple": "SH=shell SH_DE=shell SH_PM=shell SH_DE_PM=shell dotenvx run --env-file .env -- ../../bin/pm2 reload forked_app clustered_app --update-env", | ||
"reload:pid:overload": "SH=shell SH_DE=shell SH_PM=shell SH_DE_PM=shell dotenvx run --env-file .env --overload -- ../../bin/pm2 reload forked_app clustered_app --update-env", | ||
"delete": "../../bin/pm2 delete ecosystem.config.cjs" | ||
}, | ||
"dependencies": { | ||
"@dotenvx/dotenvx": "^1.10.2" | ||
} | ||
} |