File tree 5 files changed +90
-0
lines changed
5 files changed +90
-0
lines changed Original file line number Diff line number Diff line change
1
+ DE = dotenv
2
+ SH_DE = dotenv
3
+ DE_PM = dotenv
4
+ SH_DE_PM = dotenv
Original file line number Diff line number Diff line change
1
+
2
+ To start http application in cluster mode:
3
+
4
+ ``` bash
5
+ $ pm2 start ecosystem.config.js
6
+ # OR
7
+ $ pm2 start http.js -i max
8
+ ```
Original file line number Diff line number Diff line change
1
+ module . exports = {
2
+ apps : [
3
+ {
4
+ name : 'forked_app' ,
5
+ script : './index.js' ,
6
+ env : {
7
+ PORT : 8001 ,
8
+ PM : 'pm2' ,
9
+ SH_PM : 'pm2' ,
10
+ DE_PM : 'pm2' ,
11
+ SH_DE_PM : 'pm2' ,
12
+ } ,
13
+ } ,
14
+ {
15
+ name : 'clustered_app' ,
16
+ script : './index.js' ,
17
+ instances : 2 ,
18
+ exec_mode : 'cluster' ,
19
+ env : {
20
+ PORT : 8002 ,
21
+ PM : 'pm2' ,
22
+ SH_PM : 'pm2' ,
23
+ DE_PM : 'pm2' ,
24
+ SH_DE_PM : 'pm2' ,
25
+ } ,
26
+ } ,
27
+ ] ,
28
+ } ;
Original file line number Diff line number Diff line change
1
+ import http from 'http' ;
2
+
3
+ const {
4
+ PORT ,
5
+ SH ,
6
+ DE ,
7
+ PM ,
8
+ SH_DE ,
9
+ SH_PM ,
10
+ DE_PM ,
11
+ SH_DE_PM ,
12
+ } = process . env ;
13
+
14
+ http . createServer ( ( req , res ) => {
15
+ res . writeHead ( 200 ) ;
16
+ res . end ( JSON . stringify ( {
17
+ SH ,
18
+ DE ,
19
+ PM ,
20
+ SH_DE ,
21
+ SH_PM ,
22
+ DE_PM ,
23
+ SH_DE_PM ,
24
+ } , null , 2 ) ) ;
25
+ } ) . listen ( PORT , '0.0.0.0' , ( ) => {
26
+ console . log ( `App listening on port ${ PORT } ` ) ;
27
+ } ) ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " dotenvx-pm2" ,
3
+ "version" : " 1.0.0" ,
4
+ "description" : " Example usage of dotenvx with pm2" ,
5
+ "main" : " index.js" ,
6
+ "type" : " module" ,
7
+ "author" : " Michael Kalygin" ,
8
+ "license" : " MIT" ,
9
+ "scripts" : {
10
+ "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" ,
11
+ "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" ,
12
+ "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" ,
13
+ "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" ,
14
+ "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" ,
15
+ "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" ,
16
+ "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" ,
17
+ "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" ,
18
+ "delete" : " ../../bin/pm2 delete ecosystem.config.cjs"
19
+ },
20
+ "dependencies" : {
21
+ "@dotenvx/dotenvx" : " ^1.10.2"
22
+ }
23
+ }
You can’t perform that action at this time.
0 commit comments