Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ language: node_js
node_js:
- '6'
- '8'
- '9'
- '10'
install:
- npm i npminstall && npminstall
script:
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,7 @@ environment:
matrix:
- nodejs_version: '6'
- nodejs_version: '8'
- nodejs_version: '9'
- nodejs_version: '10'

install:
- ps: Install-Product node $env:nodejs_version
Expand Down
11 changes: 7 additions & 4 deletions lib/cmd/start.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ const path = require('path');

const Command = require('../command');
const debug = require('debug')('egg-script:start');
const { exec } = require('mz/child_process');
const { execFile } = require('mz/child_process');
const fs = require('mz/fs');
const homedir = require('node-homedir');
const mkdirp = require('mz-modules/mkdirp');
Expand DownExpand Up@@ -232,12 +232,15 @@ class StartCommand extends Command {

if (hasError) {
try {
const [ stdout ] = yield exec('tail -n 100 ' + stderr);
const args = [ '-n', '100', stderr ];
this.logger.error('tail %s', args.join(' '));
const [ stdout ] = yield execFile('tail', args);
this.logger.error('Got error when startup: ');
this.logger.error(stdout);
} catch (_) {
// nothing
} catch (err) {
this.logger.error('ignore tail error: %s', err);
}

isSuccess = ignoreStdErr;
this.logger.error('Start got error, see %s', stderr);
this.logger.error('Or use `--ignore-stderr` to ignore stderr at startup.');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -50,7 +50,7 @@
"bin"
],
"ci": {
"version": "6, 8, 9"
"version": "6, 8, 10"
},
"bug": {
"url": "https://github.com/eggjs/egg/issues"
Expand Down
29 changes: 28 additions & 1 deletion test/start.test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -307,6 +307,7 @@ describe('test/start.test.js', () => {
before(function*(){
yieldutils.cleanup(fixturePath);
yieldrimraf(logDir);
yieldrimraf(path.join(fixturePath,'start-fail'));
yieldmkdirp(logDir);
});

Expand All@@ -315,6 +316,7 @@ describe('test/start.test.js', () => {
yieldutils.cleanup(fixturePath);
yieldrimraf(path.join(fixturePath,'stdout.log'));
yieldrimraf(path.join(fixturePath,'stderr.log'));
yieldrimraf(path.join(fixturePath,'start-fail'));
});

it('should start',function*(){
Expand All@@ -332,6 +334,30 @@ describe('test/start.test.js', () => {
content=yieldfs.readFile(stderr,'utf-8');
assert(content==='');
});

it('should start with insecurity --stderr argument',function*(){
constcwd=path.join(__dirname,'fixtures/status');
mm(process.env,'ERROR','error message');

conststdout=path.join(fixturePath,'start-fail/stdout.log');
conststderr=path.join(fixturePath,'start-fail/stderr.log');
constmalicious=path.join(fixturePath,'start-fail/malicious');
app=coffee.fork(eggBin,[
'start','--workers=1','--daemon',`--stdout=${stdout}`,
`--stderr=${stderr}; touch ${malicious}`,
cwd,
]);
// app.debug();

yieldsleep(waitTime);

constcontent=yieldfs.readFile(stdout,'utf-8');
assert(!content.match(/custom-frameworkstartedonhttp:\/\/127\.0\.0\.1:7001/));
letexists=yieldfs.exists(stderr);
assert(!exists);
exists=yieldfs.exists(malicious);
assert(!exists);
});
});

describe('read cluster config',()=>{
Expand DownExpand Up@@ -520,10 +546,11 @@ describe('test/start.test.js', () => {
if(isWin)stderr=stderr.replace(/\\/g,'\\\\');

constapp=coffee.fork(eggBin,['start','--daemon','--workers=1'],{ cwd });
// app.debug()
// app.debug();
// TODO: find a windows replacement for tail command
if(!isWin)app.expect('stderr',/nodejs.Error:errormessage/);
yieldapp.expect('stderr',newRegExp(`Start got error, see ${stderr}`))
.expect('stderr',/Goterrorwhenstartup/)
.expect('code',1)
.end();
});
Expand Down