From 1e57f377fbcbc935e6b1cc25ad55ef5d6655f7a5 Mon Sep 17 00:00:00 2001 From: Ayc0 <benjamin.koltes@gmail.com> Date: Sat, 14 Apr 2018 11:16:46 +0200 Subject: [PATCH] Only build in prod --- scripts/ecosystem.config.json | 6 +++++- scripts/update_server.sh | 27 +++++++++++++++------------ server/index.js | 1 - server/socket.js | 4 ++-- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/scripts/ecosystem.config.json b/scripts/ecosystem.config.json index 8ae88c4..a7576e3 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 8b4f37a..c59ad3a 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 70c1aa0..9361359 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 b9da646..dfe5cfe 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; }) -- GitLab