diff --git a/scripts/ecosystem.config.json b/scripts/ecosystem.config.json index 8ae88c496429a41326588e1e40b7a8e9db03fa78..a7576e3bf4741563faab7d9c70709267ec050e41 100644 --- a/scripts/ecosystem.config.json +++ b/scripts/ecosystem.config.json @@ -4,7 +4,11 @@ "script": "server/index.js", "name": "tv-panel", "instances": "1", - "exec_mode": "cluster" + "exec_mode": "cluster", + "watch": false, + "env": { + "NODE_ENV": "production" + } } ] } diff --git a/scripts/update_server.sh b/scripts/update_server.sh index 8b4f37a2162ff46504765674725b12cced171230..c59ad3adbb48c58a1c33996ff16722c84ef88d13 100755 --- a/scripts/update_server.sh +++ b/scripts/update_server.sh @@ -1,18 +1,21 @@ #!/bin/bash -# Pull code -git fetch -# git reset --hard origin/master +if [ $NODE_ENV = "production" ] +then + # Pull code + git fetch + # git reset --hard origin/master -# Install deps -yarn install --pure-lockfile + # Install deps + yarn install --pure-lockfile -# Build front -yarn build:front + # Build front + yarn build:front -# Restart server -pm2 startOrRestart ./scripts/ecosystem.config.json + # Restart server + # pm2 startOrRestart ./scripts/ecosystem.config.json -# Restart screen -screen -S TVPanelScreen -X quit -./scripts/start_tv_panel.sh + # Restart screen + # screen -S TVPanelScreen -X quit + # ./scripts/start_tv_panel.sh +fi \ No newline at end of file diff --git a/server/index.js b/server/index.js index 70c1aa05ee2b48a3136897fbcf29bf0d4333577c..9361359b10407328dde9f07c8c4c55b56f09383c 100644 --- a/server/index.js +++ b/server/index.js @@ -12,7 +12,6 @@ const server = (req, res) => { if (url === '') { url = 'index.html'; } - console.log(url); const askedPath = path.resolve(__dirname, `../front/build/${url}`); const filePath = fs.existsSync(askedPath) ? askedPath : indexPath; fs.readFile(filePath, (err, data) => { diff --git a/server/socket.js b/server/socket.js index b9da6466b124993b0719a761e43a1c5915a8164c..dfe5cfe3a4b64bddfcaa532f71296c7da5e7eaa5 100644 --- a/server/socket.js +++ b/server/socket.js @@ -16,8 +16,8 @@ const useDummy = false; let version; const checkVersion = (newVersion) => { - console.log(version !== newVersion ? 'Update code' : ''); if (version && version !== newVersion) { + console.log('Update code'); const updateServer = spawn(path.resolve(__dirname, '../scripts/update_server.sh')); updateServer.stdout.on('data', (data) => { process.stdout.write(data); @@ -35,7 +35,7 @@ const doScreenApiRequest = (socket, userid = null) => { }) .then(rawRes => rawRes.json()) .then(async (res) => { - await checkVersion(res.version); + checkVersion(res.version); socket.emit('panel_data', res); return res.ttl; })