mirror of
https://github.com/strapi/strapi.git
synced 2025-10-17 11:08:14 +00:00
Review app start logs
This commit is contained in:
parent
7bcebb3caa
commit
f6f077a996
@ -13,7 +13,7 @@ const _ = require('lodash');
|
||||
// Following this discussion https://stackoverflow.com/questions/18082/validate-decimal-numbers-in-javascript-isnumeric this function is the best implem to determine if a value is a valid number candidate
|
||||
const isNumeric = (value) => {
|
||||
return !isNaN(parseFloat(value)) && isFinite(value);
|
||||
}
|
||||
};
|
||||
|
||||
/* eslint-disable prefer-template */
|
||||
/*
|
||||
|
@ -13,6 +13,7 @@ const cluster = require('cluster');
|
||||
// Public dependencies
|
||||
const fs = require('fs');
|
||||
const _ = require('lodash');
|
||||
const {cyan} = require('chalk');
|
||||
|
||||
// Logger.
|
||||
const { cli, logger } = require('strapi-utils');
|
||||
@ -27,7 +28,7 @@ const { cli, logger } = require('strapi-utils');
|
||||
module.exports = function(appPath = '') {
|
||||
// Check that we're in a valid Strapi project.
|
||||
if (!cli.isStrapiApp()) {
|
||||
return logger.error('This command can only be used inside a Strapi project.');
|
||||
return console.log(`⛔️ ${cyan('strapi start')} can only be used inside a Strapi project.`);
|
||||
}
|
||||
|
||||
appPath = path.join(process.cwd(), appPath);
|
||||
|
@ -112,19 +112,21 @@ class Strapi extends EventEmitter {
|
||||
// Launch server.
|
||||
this.server.listen(this.config.port, err => {
|
||||
if (err) {
|
||||
this.log.debug(`Server wasn't able to start properly.`);
|
||||
console.error(err);
|
||||
this.log.debug(`⚠️ Server wasn't able to start properly.`);
|
||||
this.log.error(err);
|
||||
return this.stop();
|
||||
}
|
||||
|
||||
this.log.info('Server started in ' + this.config.appPath);
|
||||
this.log.info('Your server is running at ' + this.config.url);
|
||||
this.log.debug('Time: ' + new Date());
|
||||
this.log.debug('Launched in: ' + (Date.now() - this.config.launchedAt) + ' ms');
|
||||
this.log.debug('Environment: ' + this.config.environment);
|
||||
this.log.debug('Process PID: ' + process.pid);
|
||||
this.log.debug(`Version: ${this.config.info.strapi} (node v${this.config.info.node})`);
|
||||
this.log.info('Time: ' + new Date());
|
||||
this.log.info('Launched in: ' + (Date.now() - this.config.launchedAt) + ' ms');
|
||||
this.log.info('Environment: ' + this.config.environment);
|
||||
this.log.info('Process PID: ' + process.pid);
|
||||
this.log.info(`Version: ${this.config.info.strapi} (node v${this.config.info.node})`);
|
||||
this.log.info('To shut down your server, press <CTRL> + C at any time');
|
||||
console.log();
|
||||
this.log.info(`☄️ Admin panel: ${this.config.url}/admin`);
|
||||
this.log.info(`⚡️ Server: ${this.config.url}`);
|
||||
console.log();
|
||||
|
||||
// Emit started event.
|
||||
this.emit('server:started');
|
||||
@ -134,8 +136,8 @@ class Strapi extends EventEmitter {
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
this.log.debug(`Server wasn't able to start properly.`);
|
||||
console.error(err);
|
||||
this.log.debug(`⛔️ Server wasn't able to start properly.`);
|
||||
this.log.error(err);
|
||||
this.stop();
|
||||
}
|
||||
}
|
||||
@ -154,7 +156,7 @@ class Strapi extends EventEmitter {
|
||||
|
||||
this.server.on('error', err => {
|
||||
if (err.code === 'EADDRINUSE') {
|
||||
this.log.debug(`Server wasn't able to start properly.`);
|
||||
this.log.debug(`⛔️ Server wasn't able to start properly.`);
|
||||
this.log.error(`The port ${err.port} is already used by another application.`);
|
||||
this.stop();
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user