From 289e7839c611b20242895e97f5a52807b8aa2205 Mon Sep 17 00:00:00 2001 From: lefuturiste Date: Sun, 26 Jul 2020 13:43:13 +0000 Subject: [PATCH] feat: pm2 support and start script for production env --- ecosystem.config.js | 18 ++++++++++++++++++ package.json | 4 ++-- start.sh | 2 ++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 ecosystem.config.js create mode 100644 start.sh diff --git a/ecosystem.config.js b/ecosystem.config.js new file mode 100644 index 0000000..e9015af --- /dev/null +++ b/ecosystem.config.js @@ -0,0 +1,18 @@ +module.exports = { + apps: [{ + name: "fva_server", + script: "./dist/app.js", + env: { + NODE_ENV: "development" + }, + env_test: { + NODE_ENV: "test", + }, + env_staging: { + NODE_ENV: "staging", + }, + env_production: { + NODE_ENV: "production" + } + }] +} diff --git a/package.json b/package.json index 63b3293..b3a71fb 100644 --- a/package.json +++ b/package.json @@ -48,10 +48,10 @@ "test": "jest --verbose --detectOpenHandles", "test-watch": "jest --verbose --watchAll", "dev": "./node_modules/.bin/tsc --watch", - "serve": "./node_modules/.bin/nodemon dist/app.js", + "serve": "env ASSETS_PATH=./assets/development ./node_modules/.bin/nodemon dist/app.js", "build": "./node_modules/.bin/tsc", "assets": "./node_modules/.bin/gulp build", - "start": "node app.js" + "start": "env ASSETS_PATH=./assets/production node ./dist/app.js" }, "main": "dist/index.js", "devDependencies": { diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..ec648b2 --- /dev/null +++ b/start.sh @@ -0,0 +1,2 @@ +pm2 start --name fva_server npm -- start +