From 08dabb0daa2c22bac2971b9945c1a572901061cb Mon Sep 17 00:00:00 2001 From: tc-imba Date: Tue, 23 Jan 2018 22:31:18 +0800 Subject: [PATCH 1/2] rename init to system --- src/models/submission.js | 15 +++++++++++++++ src/services/init.js | 23 ----------------------- src/services/system.js | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 23 deletions(-) delete mode 100644 src/services/init.js create mode 100644 src/services/system.js diff --git a/src/models/submission.js b/src/models/submission.js index 9956ba0..8310277 100644 --- a/src/models/submission.js +++ b/src/models/submission.js @@ -163,6 +163,21 @@ export default () => { }).exec(); }; + SubmissionSchema.methods.resetExceptionAsync = async function() { + + + if (this.status === Submission.STATUS_RUNNING) { + // reset state to effective + this.status = Submission.STATUS_EFFECTIVE; + await this.save(); + } else if (this.status === Submission.STATUS_PENDING || + this.status === Submission.STATUS_COMPILING) { + // resend compile request + this.taskToken = null; + await Submission.createCompileTaskAsync(this); + } + }; + /** * Check whether a user is allowed to submit new code * diff --git a/src/services/init.js b/src/services/init.js deleted file mode 100644 index 1537ebe..0000000 --- a/src/services/init.js +++ /dev/null @@ -1,23 +0,0 @@ -export default async () => { - - await DI.model.sys.setAsync('initialized', false); - await DI.model.sys.setAsync('readonly', true); - - await DI.model.sys.setAsync('initialized', true); - await DI.model.sys.setAsync('readonly', false); - - let readyExit = false; - process.on('SIGINT', async () => { - DI.logger.info('Server received SIGINT, exiting'); - if (!readyExit) { - readyExit = true; - await DI.model.sys.setAsync('readonly', true); - setInterval(async () => { - // waiting for all process ending - process.exit(0); - }, 1000); - } - }); - -}; - diff --git a/src/services/system.js b/src/services/system.js new file mode 100644 index 0000000..f411080 --- /dev/null +++ b/src/services/system.js @@ -0,0 +1,36 @@ +import _ from 'lodash'; + +export default async () => { + + const system = { + initialized: false, + init: async () => { + system.initialized = false; + await DI.model.sys.setAsync('readonly', true); + + const sdocs = await DI.models.getExceptionSubmissionAsync(); + _.forEach(sdocs, sdoc => { + + }); + + system.initialized = true; + await DI.model.sys.setAsync('readonly', false); + }, + }; + + let readyExit = false; + process.on('SIGINT', async () => { + DI.logger.info('Server received SIGINT, exiting'); + if (!readyExit) { + readyExit = true; + await DI.model.sys.setAsync('readonly', true); + setInterval(async () => { + // waiting for all process ending + process.exit(0); + }, 1000); + } + }); + + return system; +}; + From bb8c1e30bd46adaab666d378bf822c44db95e421 Mon Sep 17 00:00:00 2001 From: tc-imba Date: Tue, 23 Jan 2018 23:25:34 +0800 Subject: [PATCH 2/2] update dependencies --- README.md | 3 ++ package.json | 66 ++++++++++++++++++++-------------------- src/models/submission.js | 2 +- webpack.config.babel.js | 1 + 4 files changed, 38 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 2fc14c9..fae8282 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # GOMOKU BRAIN COMPETITION [![Build Status](https://travis-ci.org/SSTIA/fun-portal.svg?branch=master)](https://travis-ci.org/SSTIA/fun-portal) +[![experimental](http://badges.github.io/stability-badges/dist/experimental.svg)](http://github.com/badges/stability-badges) +[![GPL Licence](https://badges.frapsoft.com/os/gpl/gpl.svg?v=103)](https://opensource.org/licenses/GPL-3.0/) +[![David](https://david-dm.org/SSTIA/fun-portal.svg)](https://david-dm.org/SSTIA/fun-portal) ## Introduction diff --git a/package.json b/package.json index aff60d7..b401c09 100644 --- a/package.json +++ b/package.json @@ -19,70 +19,70 @@ }, "dependencies": { "aigle": "^1.10.1", - "app-module-path": "^2.0.0", - "babel-runtime": "^6.11.6", + "app-module-path": "^2.2.0", + "babel-runtime": "^6.26.0", "basic-auth": "^2.0.0", "bcrypt-as-promised": "^1.1.0", - "bluebird": "^3.4.6", - "body-parser": "^1.15.2", + "bluebird": "^3.5.1", + "body-parser": "^1.18.2", "chalk": "^2.3.0", - "clipboard": "^1.5.15", - "compression": "^1.6.2", + "clipboard": "^1.7.1", + "compression": "^1.7.1", "connect-mongo": "^2.0.1", "cookie-parser": "^1.4.3", "csurf": "^1.9.0", "dg-error-factory": "^1.0.2", "dg-framework": "^2.0.2", - "diff-dom": "^2.1.0", + "diff-dom": "^2.3.1", "elo-rank": "^1.0.3", "eventemitter2": "^5.0.1", - "express": "^4.14.0", + "express": "^4.16.2", "express-decorators": "^0.5.0", - "express-session": "^1.14.1", - "filesize": "^3.3.0", + "express-session": "^1.15.6", + "filesize": "^3.5.11", "flex-layout-attribute": "^1.0.3", "fs-promise": "^2.0.3", "gridfs-stream": "^1.1.1", "helmet": "^3.9.0", - "jquery": "^3.1.1", + "jquery": "^3.3.1", "jquery-scroll-lock": "^3.1.3", "jquery.easing": "^1.4.1", "jquery.transit": "^0.9.12", - "lodash": "^4.16.2", - "method-override": "^2.3.6", - "moment": "^2.15.1", - "mongoose": "^4.13.9", - "morgan": "^1.7.0", - "multer": "^1.2.0", + "lodash": "^4.17.4", + "method-override": "^2.3.10", + "moment": "^2.20.1", + "mongoose": "^5.0.1", + "morgan": "^1.9.0", + "multer": "^1.3.0", "normalize.css": "^7.0.0", "nunjucks": "^3.0.1", - "oauth": "^0.9.14", + "oauth": "^0.9.15", "oauth-jaccount": "^0.0.1", - "open-color": "^1.3.2", + "open-color": "^1.6.2", "prism-themes": "^1.0.0", - "prismjs": "^1.5.1", - "queue": "^4.0.0", + "prismjs": "^1.10.0", + "queue": "^4.4.2", "rascal": "breeswish/rascal#promisify-friendly", - "redis": "^2.6.3", - "request": "^2.75.0", - "request-promise-native": "^1.0.3", + "redis": "^2.8.0", + "request": "^2.83.0", + "request-promise-native": "^1.0.5", "rupture": "^0.7.1", "slideout": "^1.0.1", "socket.io": "^2.0.4", "socket.io-client": "^2.0.4", - "source-map-support": "^0.5.0", + "source-map-support": "^0.5.2", "sticky-kit": "^1.1.3", - "tether": "^1.3.7", + "tether": "^1.4.3", "tether-drop": "^1.4.2", "timeago.js": "^3.0.2", - "uuid": "^3.1.0", + "uuid": "^3.2.1", "validator": "^9.2.0", - "winston": "^2.2.0", + "winston": "^2.4.0", "yargs": "^10.1.1" }, "devDependencies": { "autoprefixer": "^7.2.4", - "babel-core": "^6.16.0", + "babel-core": "^6.26.0", "babel-eslint": "^8.2.1", "babel-loader": "^7.1.2", "babel-plugin-lodash": "^3.3.2", @@ -91,9 +91,9 @@ "babel-preset-env": "^1.6.1", "babel-preset-stage-0": "^6.24.1", "copy-webpack-plugin": "^4.3.1", - "css-loader": "^0.28.8", + "css-loader": "^0.28.9", "del": "^3.0.0", - "eslint": "^4.15.0", + "eslint": "^4.16.0", "eslint-loader": "^1.5.0", "eslint-plugin-babel": "^4.1.2", "extract-text-webpack-plugin": "^3.0.2", @@ -104,13 +104,13 @@ "gulp-babel": "^7.0.0", "gulp-eslint": "^4.0.1", "gulp-file-cache": "0.0.1", - "gulp-iconfont": "^9.0.2", + "gulp-iconfont": "^9.1.0", "gulp-nodemon": "^2.2.1", "gulp-nunjucks": "^3.1.1", "gulp-plumber": "^1.2.0", "gulp-sourcemaps": "^2.6.3", "gulp-svgmin": "^1.2.3", - "happypack": "^4.0.0", + "happypack": "^4.0.1", "postcss-loader": "^2.0.10", "style-loader": "^0.19.1", "stylus": "^0.54.5", diff --git a/src/models/submission.js b/src/models/submission.js index 8310277..13cfa4e 100644 --- a/src/models/submission.js +++ b/src/models/submission.js @@ -164,7 +164,7 @@ export default () => { }; SubmissionSchema.methods.resetExceptionAsync = async function() { - + if (this.status === Submission.STATUS_RUNNING) { // reset state to effective diff --git a/webpack.config.babel.js b/webpack.config.babel.js index 6ee86ea..1bb10a8 100644 --- a/webpack.config.babel.js +++ b/webpack.config.babel.js @@ -132,6 +132,7 @@ module.exports = { }, }, ], + threads: 4, }), new webpack.ProvidePlugin({