提交 4d3df865 编写于 作者: J Jason Park

Move from heroku to aws ec2 (Close #229)

上级 a051e040
...@@ -4,3 +4,4 @@ ...@@ -4,3 +4,4 @@
/npm-debug.log /npm-debug.log
/src/backend/public /src/backend/public
.DS_Store .DS_Store
/pm2.config.js
...@@ -8,8 +8,7 @@ ...@@ -8,8 +8,7 @@
"build": "npm run build:frontend && npm run build:backend", "build": "npm run build:frontend && npm run build:backend",
"build:frontend": "NODE_ENV=production node ./node_modules/webpack/bin/webpack --bail --progress --config webpack.frontend.config.js", "build:frontend": "NODE_ENV=production node ./node_modules/webpack/bin/webpack --bail --progress --config webpack.frontend.config.js",
"build:backend": "NODE_ENV=production node ./node_modules/webpack/bin/webpack --bail --progress --config webpack.backend.config.js", "build:backend": "NODE_ENV=production node ./node_modules/webpack/bin/webpack --bail --progress --config webpack.backend.config.js",
"lint": "./node_modules/.bin/eslint --fix src", "lint": "./node_modules/.bin/eslint --fix src"
"heroku-postbuild": "npm run build"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
......
import path from 'path';
import express from 'express'; import express from 'express';
import morgan from 'morgan'; import morgan from 'morgan';
import cookieParser from 'cookie-parser'; import cookieParser from 'cookie-parser';
...@@ -5,6 +6,7 @@ import bodyParser from 'body-parser'; ...@@ -5,6 +6,7 @@ import bodyParser from 'body-parser';
import * as controllers from '/controllers'; import * as controllers from '/controllers';
import { ClientError, ForbiddenError, NotFoundError, UnauthorizedError } from '/common/error'; import { ClientError, ForbiddenError, NotFoundError, UnauthorizedError } from '/common/error';
import webhook from '/common/webhook'; import webhook from '/common/webhook';
import { execute } from '/common/util';
const app = express(); const app = express();
app.use(morgan('tiny')); app.use(morgan('tiny'));
...@@ -28,4 +30,19 @@ app.use((err, req, res, next) => { ...@@ -28,4 +30,19 @@ app.use((err, req, res, next) => {
console.error(err); console.error(err);
}); });
const rootPath = path.resolve(__dirname, '..', '..');
webhook.on('algorithm-visualizer', event => {
switch (event) {
case 'push':
execute([
'git fetch',
'git reset --hard origin/master',
'npm install',
'npm run build',
'pm2 startOrRestart ./pm2.config.js',
].join(' && '), rootPath);
break;
}
});
export default app; export default app;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册