Skip to content

Commit fca60ef

Browse files
committed
Run pull.sh with pm2 when webhooked
1 parent 42e3d97 commit fca60ef

File tree

5 files changed

+6
-15
lines changed

5 files changed

+6
-15
lines changed

bin/pull.sh renamed to bin/pull

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env bash
22

33
git fetch &&
4+
! git diff-index --quiet origin/master &&
45
git reset --hard origin/master &&
5-
npm --production=false install &&
6+
npm install &&
67
npm run build

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
"build": "npm run build:frontend && npm run build:backend",
1010
"build:frontend": "NODE_ENV=production node ./node_modules/webpack/bin/webpack --bail --progress --config webpack.frontend.config.js",
1111
"build:backend": "NODE_ENV=production node ./node_modules/webpack/bin/webpack --bail --progress --config webpack.backend.config.js",
12+
"pull": "NODE_ENV=development ./bin/pull",
13+
"pm2": "npm run pull ; npm start",
1214
"lint": "./node_modules/.bin/eslint --fix src"
1315
},
1416
"repository": {

src/backend/common/util.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@ const execute = (command, cwd, { stdout = process.stdout, stderr = process.stder
1414
if (stderr) child.stderr.pipe(stderr);
1515
});
1616

17-
const spawn = (command, args, cwd, { stdout = process.stdout, stderr = process.stderr } = {}) => new Promise((resolve, reject) => {
18-
if (!cwd) return reject(new Error('CWD Not Specified'));
19-
const child = child_process.spawn(command, args, { cwd });
20-
child.on('close', code => code ? reject(new Error(`Process exited with code: ${code}`)) : resolve());
21-
if (stdout) child.stdout.pipe(stdout);
22-
if (stderr) child.stderr.pipe(stderr);
23-
});
24-
2517
const createKey = name => name.toLowerCase().trim().replace(/[^\w \-]/g, '').replace(/ /g, '-');
2618

2719
const isDirectory = dirPath => fs.lstatSync(dirPath).isDirectory();
@@ -43,7 +35,6 @@ const getDescription = files => {
4335

4436
export {
4537
execute,
46-
spawn,
4738
createKey,
4839
isDirectory,
4940
listFiles,

src/backend/controllers/algorithms.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import fs from 'fs-extra';
33
import { execute } from '/common/util';
44
import webhook from '/common/webhook';
55
import hierarchy from '/common/hierarchy';
6-
import { NotFoundError } from '../common/error';
6+
import { NotFoundError } from '/common/error';
77

88
const router = express.Router();
99

src/backend/index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import path from 'path';
21
import express from 'express';
32
import morgan from 'morgan';
43
import cookieParser from 'cookie-parser';
54
import bodyParser from 'body-parser';
65
import * as controllers from '/controllers';
76
import { ClientError, ForbiddenError, NotFoundError, UnauthorizedError } from '/common/error';
87
import webhook from '/common/webhook';
9-
import { spawn } from '/common/util';
108
import hierarchy from '/common/hierarchy';
119

1210
const app = express();
@@ -32,11 +30,10 @@ app.use((err, req, res, next) => {
3230
});
3331
app.hierarchy = hierarchy;
3432

35-
const rootPath = path.resolve(__dirname, '..', '..');
3633
webhook.on('algorithm-visualizer', event => {
3734
switch (event) {
3835
case 'push':
39-
spawn('sh', ['./bin/pull.sh'], rootPath).then(() => process.exit(0));
36+
process.exit(0);
4037
break;
4138
}
4239
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy