Skip to content
Snippets Groups Projects
Commit 1e57f377 authored by Ayc0's avatar Ayc0
Browse files

Only build in prod

parent 4092e8b0
Branches
No related tags found
No related merge requests found
...@@ -4,7 +4,11 @@ ...@@ -4,7 +4,11 @@
"script": "server/index.js", "script": "server/index.js",
"name": "tv-panel", "name": "tv-panel",
"instances": "1", "instances": "1",
"exec_mode": "cluster" "exec_mode": "cluster",
"watch": false,
"env": {
"NODE_ENV": "production"
}
} }
] ]
} }
#!/bin/bash #!/bin/bash
if [ $NODE_ENV = "production" ]
then
# Pull code # Pull code
git fetch git fetch
# git reset --hard origin/master # git reset --hard origin/master
...@@ -11,8 +13,9 @@ yarn install --pure-lockfile ...@@ -11,8 +13,9 @@ yarn install --pure-lockfile
yarn build:front yarn build:front
# Restart server # Restart server
pm2 startOrRestart ./scripts/ecosystem.config.json # pm2 startOrRestart ./scripts/ecosystem.config.json
# Restart screen # Restart screen
screen -S TVPanelScreen -X quit # screen -S TVPanelScreen -X quit
./scripts/start_tv_panel.sh # ./scripts/start_tv_panel.sh
fi
\ No newline at end of file
...@@ -12,7 +12,6 @@ const server = (req, res) => { ...@@ -12,7 +12,6 @@ const server = (req, res) => {
if (url === '') { if (url === '') {
url = 'index.html'; url = 'index.html';
} }
console.log(url);
const askedPath = path.resolve(__dirname, `../front/build/${url}`); const askedPath = path.resolve(__dirname, `../front/build/${url}`);
const filePath = fs.existsSync(askedPath) ? askedPath : indexPath; const filePath = fs.existsSync(askedPath) ? askedPath : indexPath;
fs.readFile(filePath, (err, data) => { fs.readFile(filePath, (err, data) => {
......
...@@ -16,8 +16,8 @@ const useDummy = false; ...@@ -16,8 +16,8 @@ const useDummy = false;
let version; let version;
const checkVersion = (newVersion) => { const checkVersion = (newVersion) => {
console.log(version !== newVersion ? 'Update code' : '');
if (version && version !== newVersion) { if (version && version !== newVersion) {
console.log('Update code');
const updateServer = spawn(path.resolve(__dirname, '../scripts/update_server.sh')); const updateServer = spawn(path.resolve(__dirname, '../scripts/update_server.sh'));
updateServer.stdout.on('data', (data) => { updateServer.stdout.on('data', (data) => {
process.stdout.write(data); process.stdout.write(data);
...@@ -35,7 +35,7 @@ const doScreenApiRequest = (socket, userid = null) => { ...@@ -35,7 +35,7 @@ const doScreenApiRequest = (socket, userid = null) => {
}) })
.then(rawRes => rawRes.json()) .then(rawRes => rawRes.json())
.then(async (res) => { .then(async (res) => {
await checkVersion(res.version); checkVersion(res.version);
socket.emit('panel_data', res); socket.emit('panel_data', res);
return res.ttl; return res.ttl;
}) })
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment