From 17de6a96b1789fe55da82fab7012d349cbb67e66 Mon Sep 17 00:00:00 2001 From: mistakia <1823355+mistakia@users.noreply.github.com> Date: Thu, 16 Jan 2025 12:10:28 -0500 Subject: [PATCH] chore: setup deploy --- ecosystem.config.js | 22 ---------------------- package.json | 3 ++- server.pm2.config.js | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 23 deletions(-) delete mode 100644 ecosystem.config.js create mode 100644 server.pm2.config.js diff --git a/ecosystem.config.js b/ecosystem.config.js deleted file mode 100644 index 74f96b0..0000000 --- a/ecosystem.config.js +++ /dev/null @@ -1,22 +0,0 @@ -module.exports = { - apps: [ - { - name: 'nanodb-api', - script: 'server.mjs', - watch: './api', - env_production: { - NODE_ENV: 'production' - }, - max_memory_restart: '2G' - }, - { - name: 'nanodb-sync-websocket', - script: 'scripts/import-websocket.mjs', - watch: '.', - env_production: { - NODE_ENV: 'production' - }, - max_memory_restart: '2G' - } - ] -} diff --git a/package.json b/package.json index 9c7c33b..4a42481 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,8 @@ "start": "NODE_ENV=development node server", "lint": "eslint . --ext js,mjs", "prettier": "prettier --write .", - "test": "TZ=America/New_York NODE_ENV=test TEST=all mocha --exit" + "test": "TZ=America/New_York NODE_ENV=test TEST=all mocha --exit", + "deploy": "pm2 deploy server.pm2.config.js production" }, "dependencies": { "bignumber.js": "^9.0.1", diff --git a/server.pm2.config.js b/server.pm2.config.js new file mode 100644 index 0000000..56141b1 --- /dev/null +++ b/server.pm2.config.js @@ -0,0 +1,37 @@ +module.exports = { + apps: [ + { + name: 'nanodb-api', + script: 'server.mjs', + watch: './api', + env_production: { + NODE_ENV: 'production' + }, + max_memory_restart: '2G' + }, + { + name: 'nanodb-sync-websocket', + script: 'scripts/import-websocket.mjs', + watch: '.', + env_production: { + NODE_ENV: 'production' + }, + max_memory_restart: '2G' + } + ], + + deploy: { + production: { + user: 'root', + host: 'storage', + ref: 'origin/master', + repo: 'https://github.com/mistakia/nanodb.git', + path: '/root/league', + 'pre-deploy': 'git pull', + 'pre-deploy-local': '', + 'post-deploy': + 'source ~/.bash_profile && /home/user/.nvm/versions/node/v16.4.0/bin/yarn install && pm2 reload server.pm2.config.js --env production', + 'pre-setup': '' + } + } +}