This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import mongoose from 'mongoose'; | |
| import mongoosePaginate from 'mongoose-paginate'; | |
| import uniqueValidator from 'mongoose-unique-validator'; | |
| import createdAt from '../../core/lib/mongoose-plugins/created-at'; | |
| import updatedAt from '../../core/lib/mongoose-plugins/updated-at'; | |
| import createdBy from '../../core/lib/mongoose-plugins/created-by'; | |
| import active from '../../core/lib/mongoose-plugins/active'; | |
| import password from '../../core/lib/mongoose-plugins/password'; | |
| import fullName from '../../core/lib/mongoose-plugins/full-name'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import models from '../lib/mongo' | |
| let { Article } = models | |
| export default { | |
| addArticle: (data) => Article.create(data), | |
| getArticle: (articleId) => Article.findOne({ _id: articleId }), | |
| getAllArticles: () => Article.find(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| server.expose({ | |
| killMe : that.close.bind(this), | |
| profileCPU : profile.bind(this, 'cpu'), | |
| profileMEM : profile.bind(this, 'mem'), | |
| prepare : God.prepare, | |
| getMonitorData : God.getMonitorData, | |
| getSystemData : God.getSystemData, | |
| startProcessId : God.startProcessId, | |
| stopProcessId : God.stopProcessId, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = function ClusterMode(God) { | |
| /** | |
| * Watch folder for changes and restart | |
| * @method watch | |
| * @param {Object} pm2_env pm2 app environnement | |
| * @return MemberExpression | |
| */ | |
| God.watch = {}; | |
| God.watch._watchers = {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var pm2 = require('../..'); | |
| pm2.delete('all', function(err) { | |
| if (err) { | |
| console.error(err); | |
| return pm2.disconnect(); | |
| } | |
| pm2.start('http.js', function(err, app) { | |
| if (err) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (cluster.isMaster) { | |
| const worker = cluster.fork(); | |
| let timeout; | |
| worker.on('listening', (address) => { | |
| worker.send('shutdown'); | |
| worker.disconnect(); | |
| timeout = setTimeout(() => { | |
| worker.kill(); | |
| }, 2000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const cluster = require('cluster'); | |
| const numCPUs = require('os').cpus().length; | |
| const run = funcs => new Promise((resolve) => { | |
| if (cluster.isMaster) { | |
| let funcsIndex = 0; | |
| const funcCount = funcs.length; | |
| const finishedFuncs = new Array(Math.max(funcCount, numCPUs)).fill(false); | |
| const { workers } = cluster; | |
| const messageHandler = (message) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| /** | |
| * @file task-manager main | |
| * @module task-manager | |
| * @subpackage lib | |
| * @version 1.3.0 | |
| * @author hex7c0 <hex7c0@gmail.com> | |
| * @copyright hex7c0 2014 | |
| * @license GPLv3 | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var cluster = require('cluster'); | |
| const numCPUs = require('os').cpus().length; | |
| module.exports.create = function (options, callback) { | |
| if (cluster.isMaster) { | |
| // fork child process for notif/sms/email worker | |
| global.smsWorker = require('child_process').fork('./smsWorker'); | |
| global.emailWorker = require('child_process').fork('./emailWorker'); | |
| global.notifiWorker = require('child_process').fork('./notifWorker'); |