write placeholder page when webserver is first starting
This commit is contained in:
parent
b47435cc45
commit
f778dad589
|
@ -1,9 +1,15 @@
|
|||
let finalhandler = require('finalhandler');
|
||||
const fs = require('../../core/fs.js');
|
||||
let http = require('http');
|
||||
let serveStatic = require('serve-static');
|
||||
const {canonicalHost, defaultHost, dockerHostSwap} = require('../../utils/host');
|
||||
const utils = require('../../utils/utils.js');
|
||||
require('http-shutdown').extend();
|
||||
|
||||
require('ejs');
|
||||
const embark_building_placeholder = require('../code_generator/code_templates/embark-building-placeholder.html.ejs');
|
||||
|
||||
let isFirstStart = true;
|
||||
class Server {
|
||||
constructor(options) {
|
||||
this.dist = options.dist || 'dist/';
|
||||
|
@ -24,6 +30,12 @@ class Server {
|
|||
serve(req, res, finalhandler(req, res));
|
||||
}).withShutdown();
|
||||
|
||||
if (isFirstStart) {
|
||||
const html = embark_building_placeholder({buildingMsg: __('Embark is building, please wait...')});
|
||||
fs.mkdirpSync(this.dist); // create dist/ folder if not already exists
|
||||
fs.writeFileSync(utils.joinPath(this.dist, 'index.html'), html);
|
||||
isFirstStart = false;
|
||||
}
|
||||
|
||||
this.server.listen(this.port, this.hostname, () => {
|
||||
this.port = this.server.address().port;
|
||||
|
|
Loading…
Reference in New Issue