Setup wizard completed + restart call

This commit is contained in:
NGPixel 2017-03-28 22:29:53 -04:00
parent df4da74539
commit 4dd79170c5
4 changed files with 79 additions and 4 deletions

View File

@ -339,7 +339,20 @@ _vue2.default.use(_veeValidate2.default, {
}); });
}, 1000); }, 1000);
}, },
finish: function finish(ev) {} finish: function finish(ev) {
var self = this;
self.state = 'restart';
_lodash2.default.delay(function () {
_axios2.default.post('/restart', {}).then(function (resp) {
_lodash2.default.delay(function () {
window.location.assign(self.conf.host);
}, 10000);
}).catch(function (err) {
window.alert(err.message);
});
}, 1000);
}
} }
}); });
}); });

View File

@ -267,7 +267,18 @@ jQuery(document).ready(function ($) {
}, 1000) }, 1000)
}, },
finish: function (ev) { finish: function (ev) {
let self = this
self.state = 'restart'
_.delay(() => {
axios.post('/restart', {}).then(resp => {
_.delay(() => {
window.location.assign(self.conf.host)
}, 10000)
}).catch(err => {
window.alert(err.message)
})
}, 1000)
} }
} }
}) })

View File

@ -26,6 +26,8 @@ module.exports = (port, spinner) => {
var app = express() var app = express()
app.use(compression()) app.use(compression())
var server
// ---------------------------------------- // ----------------------------------------
// Public Assets // Public Assets
// ---------------------------------------- // ----------------------------------------
@ -165,7 +167,6 @@ module.exports = (port, spinner) => {
const gitDir = path.resolve(ROOTPATH, req.body.pathRepo) const gitDir = path.resolve(ROOTPATH, req.body.pathRepo)
let gitRemoteUrl = '' let gitRemoteUrl = ''
console.log(req.body)
if (req.body.gitUseRemote === true) { if (req.body.gitUseRemote === true) {
let urlObj = url.parse(req.body.gitUrl) let urlObj = url.parse(req.body.gitUrl)
@ -356,6 +357,23 @@ module.exports = (port, spinner) => {
}) })
}) })
/**
* Restart in normal mode
*/
app.post('/restart', (req, res) => {
res.status(204).end()
server.destroy(() => {
spinner.text = 'Setup wizard terminated. Restarting in normal mode...'
_.delay(() => {
const exec = require('execa')
exec.stdout('node', ['wiki', 'start']).then(result => {
spinner.succeed('Wiki.js is now running in normal mode!')
process.exit(0)
})
}, 1000)
})
})
// ---------------------------------------- // ----------------------------------------
// Error handling // Error handling
// ---------------------------------------- // ----------------------------------------
@ -383,8 +401,26 @@ module.exports = (port, spinner) => {
spinner.text = 'Starting HTTP server...' spinner.text = 'Starting HTTP server...'
app.set('port', port) app.set('port', port)
var server = http.createServer(app) server = http.createServer(app)
server.listen(port) server.listen(port)
var openConnections = []
server.on('connection', (conn) => {
let key = conn.remoteAddress + ':' + conn.remotePort
openConnections[key] = conn
conn.on('close', () => {
delete openConnections[key]
})
})
server.destroy = (cb) => {
server.close(cb)
for (let key in openConnections) {
openConnections[key].destroy()
}
}
server.on('error', (error) => { server.on('error', (error) => {
if (error.syscall !== 'listen') { if (error.syscall !== 'listen') {
throw error throw error

View File

@ -26,7 +26,7 @@ html(data-logic='configure')
main main
.container .container
transition(name='tst-welcome') transition(name='tst-welcome')
.welcome(style={'padding-bottom': '5px'}, v-if='state === "welcome"') .welcome(style={'padding-bottom': '5px'}, v-if='state === "welcome" || state === "restart"')
img(src='/favicons/android-icon-96x96.png', alt='Wiki.js') img(src='/favicons/android-icon-96x96.png', alt='Wiki.js')
h1 Welcome to Wiki.js! h1 Welcome to Wiki.js!
h2(style={'margin-bottom': 0}) A modern, lightweight and powerful wiki app built on NodeJS, Git and Markdown h2(style={'margin-bottom': 0}) A modern, lightweight and powerful wiki app built on NodeJS, Git and Markdown
@ -356,6 +356,21 @@ html(data-logic='configure')
button.button.is-teal(v-on:click='proceedToFinal', v-if='!loading && !final.ok') Try Again button.button.is-teal(v-on:click='proceedToFinal', v-if='!loading && !final.ok') Try Again
button.button.is-green(v-on:click='finish', v-if='loading || final.ok', v-bind:disabled='loading') Start button.button.is-green(v-on:click='finish', v-if='loading || final.ok', v-bind:disabled='loading') Start
//- ==============================================
//- RESTART
//- ==============================================
template(v-else-if='state === "restart"')
.panel
h2.panel-title.is-featured
span Restarting...
i
.panel-content.is-text
p #[i.icon-loader.animated.rotateIn.infinite] Restarting Wiki.js in normal mode...
p You'll automatically be redirected to the homepage when ready. Please be patient...
.panel-footer
button.button.is-green(disabled='disabled') Start
footer.footer footer.footer
span span
| Powered by | Powered by