npm install fixes + logs folder
This commit is contained in:
parent
e0bb77efbb
commit
f311d74a08
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,6 +2,7 @@
|
|||||||
logs
|
logs
|
||||||
*.log
|
*.log
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
|
/logs
|
||||||
|
|
||||||
# Runtime data
|
# Runtime data
|
||||||
pids
|
pids
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
[![Release](https://img.shields.io/github/release/Requarks/wiki.svg?style=flat-square&maxAge=3600)](https://github.com/Requarks/wiki/releases)
|
[![Release](https://img.shields.io/github/release/Requarks/wiki.svg?style=flat-square&maxAge=3600)](https://github.com/Requarks/wiki/releases)
|
||||||
[![License](https://img.shields.io/badge/license-AGPLv3-blue.svg?style=flat-square)](https://github.com/requarks/wiki/blob/master/LICENSE)
|
[![License](https://img.shields.io/badge/license-AGPLv3-blue.svg?style=flat-square)](https://github.com/requarks/wiki/blob/master/LICENSE)
|
||||||
[![npm](https://img.shields.io/badge/npm-wiki.js-blue.svg?style=flat-square)](https://www.npmjs.com/package/wiki.js)
|
[![npm](https://img.shields.io/badge/npm-wiki.js-blue.svg?style=flat-square)](https://www.npmjs.com/package/wiki.js)
|
||||||
[![Github All Releases](https://img.shields.io/github/downloads/Requarks/wiki/total.svg?style=flat-square)](https://github.com/Requarks/wiki/releases/latest)
|
[![npm Downloads](https://img.shields.io/npm/dt/wiki.js.svg?style=flat-square)](https://www.npmjs.com/package/wiki.js)
|
||||||
[![Build Status](https://img.shields.io/travis/Requarks/wiki/master.svg?style=flat-square)](https://travis-ci.org/Requarks/wiki)
|
[![Build Status](https://img.shields.io/travis/Requarks/wiki/master.svg?style=flat-square)](https://travis-ci.org/Requarks/wiki)
|
||||||
[![Codacy Badge](https://img.shields.io/codacy/grade/1d0217a3153c4595bdedb322263e55c8/master.svg?style=flat-square)](https://www.codacy.com/app/Requarks/wiki)
|
[![Codacy Badge](https://img.shields.io/codacy/grade/1d0217a3153c4595bdedb322263e55c8/master.svg?style=flat-square)](https://www.codacy.com/app/Requarks/wiki)
|
||||||
[![Dependency Status](https://img.shields.io/gemnasium/Requarks/wiki.svg?style=flat-square)](https://gemnasium.com/github.com/Requarks/wiki)
|
[![Dependency Status](https://img.shields.io/gemnasium/Requarks/wiki.svg?style=flat-square)](https://gemnasium.com/github.com/Requarks/wiki)
|
||||||
|
@ -8,9 +8,7 @@
|
|||||||
[![Release](https://img.shields.io/github/release/Requarks/wiki.svg?style=flat-square&maxAge=3600)](https://github.com/Requarks/wiki/releases)
|
[![Release](https://img.shields.io/github/release/Requarks/wiki.svg?style=flat-square&maxAge=3600)](https://github.com/Requarks/wiki/releases)
|
||||||
[![License](https://img.shields.io/badge/license-AGPLv3-blue.svg?style=flat-square)](https://github.com/requarks/wiki/blob/master/LICENSE)
|
[![License](https://img.shields.io/badge/license-AGPLv3-blue.svg?style=flat-square)](https://github.com/requarks/wiki/blob/master/LICENSE)
|
||||||
|
|
||||||
##### A modern, lightweight and powerful wiki app built on NodeJS, Git and Markdown
|
This npm package is an installer for Wiki.js. For information about Wiki.js, including detailed installation steps, read the following links:
|
||||||
|
|
||||||
This npm package is an installer for Wiki.js. For information about Wiki.js, use the following links:
|
|
||||||
|
|
||||||
- [Official Website](https://wiki.requarks.io/)
|
- [Official Website](https://wiki.requarks.io/)
|
||||||
- [Installation Guide](https://wiki.requarks.io/get-started.html)
|
- [Installation Guide](https://wiki.requarks.io/get-started.html)
|
||||||
|
@ -13,11 +13,21 @@ const _ = require('lodash')
|
|||||||
|
|
||||||
let installDir = path.resolve(__dirname, '../..')
|
let installDir = path.resolve(__dirname, '../..')
|
||||||
|
|
||||||
|
ora.text = 'Looking for running instances...'
|
||||||
|
pm2.connectAsync().then(() => {
|
||||||
|
return pm2.describeAsync('wiki').then(() => {
|
||||||
|
ora.text = 'Stopping and deleting from pm2...'
|
||||||
|
return pm2.deleteAsync('wiki')
|
||||||
|
}).catch(err => { // eslint-disable-line handle-callback-err
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
}).then(() => {
|
||||||
/**
|
/**
|
||||||
* Fetch version from npm package
|
* Fetch version from npm package
|
||||||
*/
|
*/
|
||||||
fs.readJsonAsync('package.json').then((packageObj) => {
|
return fs.readJsonAsync('package.json').then((packageObj) => {
|
||||||
let remoteURL = _.replace('https://github.com/Requarks/wiki/releases/download/v{0}/wiki-js.tar.gz', '{0}', packageObj.version)
|
let versionGet = _.chain(packageObj.version).split('.').take(4).join('.')
|
||||||
|
let remoteURL = _.replace('https://github.com/Requarks/wiki/releases/download/v{0}/wiki-js.tar.gz', '{0}', versionGet)
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
/**
|
/**
|
||||||
@ -42,6 +52,7 @@ fs.readJsonAsync('package.json').then((packageObj) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
})
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
ora.text = 'Installing Wiki.js npm dependencies...'
|
ora.text = 'Installing Wiki.js npm dependencies...'
|
||||||
@ -62,17 +73,19 @@ fs.readJsonAsync('package.json').then((packageObj) => {
|
|||||||
/**
|
/**
|
||||||
* Upgrade mode
|
* Upgrade mode
|
||||||
*/
|
*/
|
||||||
ora.text = 'Upgrade succeeded. Reloading Wiki.js...'
|
return new Promise((resolve, reject) => {
|
||||||
return pm2.connectAsync().then(() => {
|
ora.text = 'Upgrade succeeded. Starting Wiki.js...'
|
||||||
return pm2.restartAsync('wiki').catch(err => { // eslint-disable-line handle-callback-err
|
let npmInstallProc = exec('wiki start', {
|
||||||
return new Error('Unable to restart Wiki.js via pm2... Do a manual restart!')
|
cwd: installDir
|
||||||
}).then(() => {
|
})
|
||||||
ora.succeed('Wiki.js has restarted. Upgrade completed.')
|
npmInstallProc.stdout.pipe(process.stdout)
|
||||||
|
npmInstallProc.on('error', err => {
|
||||||
|
reject(err)
|
||||||
|
})
|
||||||
|
.on('exit', () => {
|
||||||
|
ora.succeed('Wiki.js has started. Upgrade completed.')
|
||||||
|
resolve(true)
|
||||||
})
|
})
|
||||||
}).catch(err => {
|
|
||||||
ora.fail(err)
|
|
||||||
}).finally(() => {
|
|
||||||
pm2.disconnect()
|
|
||||||
})
|
})
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
/**
|
/**
|
||||||
@ -89,4 +102,6 @@ fs.readJsonAsync('package.json').then((packageObj) => {
|
|||||||
})
|
})
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
ora.fail(err)
|
ora.fail(err)
|
||||||
|
}).finally(() => {
|
||||||
|
pm2.disconnect()
|
||||||
})
|
})
|
||||||
|
19
wiki.js
19
wiki.js
@ -1,11 +1,12 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const fs = require('fs-extra')
|
|
||||||
const ora = require('ora')
|
|
||||||
const Promise = require('bluebird')
|
const Promise = require('bluebird')
|
||||||
|
const fs = Promise.promisifyAll(require('fs-extra'))
|
||||||
|
const ora = require('ora')
|
||||||
const pm2 = Promise.promisifyAll(require('pm2'))
|
const pm2 = Promise.promisifyAll(require('pm2'))
|
||||||
const cmdr = require('commander')
|
const cmdr = require('commander')
|
||||||
|
const path = require('path')
|
||||||
|
|
||||||
const packageObj = fs.readJsonSync('package.json')
|
const packageObj = fs.readJsonSync('package.json')
|
||||||
|
|
||||||
@ -15,18 +16,24 @@ cmdr.command('start')
|
|||||||
.description('Start Wiki.js process')
|
.description('Start Wiki.js process')
|
||||||
.action(() => {
|
.action(() => {
|
||||||
let spinner = ora('Initializing...').start()
|
let spinner = ora('Initializing...').start()
|
||||||
pm2.connectAsync().then(() => {
|
fs.emptyDirAsync(path.join(__dirname, './logs')).then(() => {
|
||||||
|
return pm2.connectAsync().then(() => {
|
||||||
return pm2.startAsync({
|
return pm2.startAsync({
|
||||||
name: 'wiki',
|
name: 'wiki',
|
||||||
script: 'server.js',
|
script: 'server.js',
|
||||||
cwd: __dirname
|
cwd: __dirname,
|
||||||
|
output: path.join(__dirname, './logs/wiki-output.log'),
|
||||||
|
error: path.join(__dirname, './logs/wiki-error.log'),
|
||||||
|
minUptime: 5000,
|
||||||
|
maxRestarts: 5
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
spinner.succeed('Wiki.js has started successfully.')
|
spinner.succeed('Wiki.js has started successfully.')
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
pm2.disconnect()
|
pm2.disconnect()
|
||||||
})
|
})
|
||||||
|
})
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.error(err)
|
spinner.fail(err)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -42,7 +49,7 @@ cmdr.command('stop')
|
|||||||
pm2.disconnect()
|
pm2.disconnect()
|
||||||
})
|
})
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.error(err)
|
spinner.fail(err)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user