Process Manager feature

This commit is contained in:
NGPixel 2017-02-14 02:17:25 -05:00
parent da549cd637
commit ae7373b937
4 changed files with 57 additions and 2 deletions

View File

@ -3,6 +3,9 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/). This project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased] ## [Unreleased]
### Added
- Automated Upgrade / Re-install feature
- Automated process manager
## [v1.0-beta.5] - 2017-02-12 ## [v1.0-beta.5] - 2017-02-12
### Added ### Added

View File

@ -102,8 +102,8 @@ module.exports = {
try { try {
fs.ensureDirSync(path.resolve(ROOTPATH, appconfig.paths.data)) fs.ensureDirSync(path.resolve(ROOTPATH, appconfig.paths.data))
fs.emptyDirSync(path.resolve(ROOTPATH, appconfig.paths.data))
fs.ensureDirSync(path.resolve(ROOTPATH, appconfig.paths.data, './cache')) fs.ensureDirSync(path.resolve(ROOTPATH, appconfig.paths.data, './cache'))
fs.emptyDirSync(path.resolve(ROOTPATH, appconfig.paths.data, './cache'))
fs.ensureDirSync(path.resolve(ROOTPATH, appconfig.paths.data, './thumbs')) fs.ensureDirSync(path.resolve(ROOTPATH, appconfig.paths.data, './thumbs'))
fs.ensureDirSync(path.resolve(ROOTPATH, appconfig.paths.data, './temp-upload')) fs.ensureDirSync(path.resolve(ROOTPATH, appconfig.paths.data, './temp-upload'))

View File

@ -4,7 +4,7 @@
"description": "A modern, lightweight and powerful wiki app built on NodeJS, Git and Markdown", "description": "A modern, lightweight and powerful wiki app built on NodeJS, Git and Markdown",
"main": "server.js", "main": "server.js",
"scripts": { "scripts": {
"start": "node server", "start": "node wiki start",
"dev": "gulp dev", "dev": "gulp dev",
"test": "snyk test && standard && pug-lint ./views", "test": "snyk test && standard && pug-lint ./views",
"snyk-protect": "snyk protect", "snyk-protect": "snyk protect",
@ -40,6 +40,7 @@
"cheerio": "^0.22.0", "cheerio": "^0.22.0",
"child-process-promise": "^2.2.0", "child-process-promise": "^2.2.0",
"chokidar": "^1.6.0", "chokidar": "^1.6.0",
"commander": "^2.9.0",
"compression": "^1.6.2", "compression": "^1.6.2",
"connect-flash": "^0.1.1", "connect-flash": "^0.1.1",
"connect-mongo": "^1.3.2", "connect-mongo": "^1.3.2",
@ -76,6 +77,7 @@
"moment-timezone": "^0.5.11", "moment-timezone": "^0.5.11",
"mongoose": "^4.8.1", "mongoose": "^4.8.1",
"multer": "^1.2.1", "multer": "^1.2.1",
"ora": "^1.1.0",
"passport": "^0.3.2", "passport": "^0.3.2",
"passport-facebook": "^2.1.1", "passport-facebook": "^2.1.1",
"passport-google-oauth20": "^1.0.0", "passport-google-oauth20": "^1.0.0",

50
wiki.js Normal file
View File

@ -0,0 +1,50 @@
'use strict'
const ora = require('ora')
const Promise = require('bluebird')
const pm2 = Promise.promisifyAll(require('pm2'))
const cmdr = require('commander')
cmdr.version('1.0.0')
cmdr.command('start')
.description('Start Wiki.js process')
.action(() => {
let spinner = ora('Initializing...').start()
pm2.connectAsync().then(() => {
return pm2.startAsync({
name: 'wiki',
script: 'server.js',
cwd: __dirname
}).then(() => {
spinner.succeed('Wiki.js has started successfully.')
}).finally(() => {
pm2.disconnect()
})
}).catch(err => {
console.error(err)
process.exit(1)
})
})
cmdr.command('stop')
.description('Stop Wiki.js process')
.action(() => {
let spinner = ora('Shutting down Wiki.js...').start()
pm2.connectAsync().then(() => {
return pm2.stopAsync('wiki').then(() => {
spinner.succeed('Wiki.js has stopped successfully.')
}).finally(() => {
pm2.disconnect()
})
}).catch(err => {
console.error(err)
process.exit(1)
})
})
cmdr.parse(process.argv)
if (!process.argv.slice(2).length) {
cmdr.help()
}