Skip to content

Commit ee11ffc

Browse files
atian25popomore
authored andcommitted
Merge branch 'master' into stop-test
2 parents ef908b9 + c6cdf09 commit ee11ffc

File tree

11 files changed

+216
-89
lines changed

11 files changed

+216
-89
lines changed

History.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11

2+
2.3.0 / 2017-11-29
3+
==================
4+
5+
**features**
6+
* [[`4c41319`](http://github.com/eggjs/egg-scripts/commit/4c41319f9e309402b2ccb5c7afd5a6d3cda2453f)] - feat: support stop --title (#16) (TZ | 天猪 <<[email protected]>>)
7+
8+
2.2.0 / 2017-11-22
9+
==================
10+
11+
**features**
12+
* [[`ac58d00`](http://github.com/eggjs/egg-scripts/commit/ac58d00a974fdfff6b5c722743e4b32174963c52)] - feat: cwd maybe not baseDir (#15) (zhennann <<[email protected]>>)
13+
214
2.1.1 / 2017-11-14
315
==================
416

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ $ eggctl start [options] [baseDir]
4646
- `baseDir` - directory of application, default to `process.cwd()`.
4747
- **Options**
4848
- `port` - listening port, default to `process.env.PORT`, if unset, egg will use `7001` as default.
49-
- `title` - process title description, use for kill grep, default to `egg-server-APPNAME`.
49+
- `title` - process title description, use for kill grep, default to `egg-server-${APP_NAME}`.
5050
- `workers` - numbers of app workers, default to `process.env.EGG_WORKERS`, if unset, egg will use `os.cpus().length` as default.
5151
- `daemon` - whether run at background daemon mode.
5252
- `framework` - specify framework that can be absolute path or npm package, default to auto detect.
@@ -61,9 +61,8 @@ Stop egg gracefull.
6161

6262
```bash
6363
# stop egg
64-
$ eggctl stop [baseDir]
65-
# eggctl stop ./server
64+
$ eggctl stop [--title=example]
6665
```
6766

68-
- **Arguments**
69-
- `baseDir` - directory of application, default to `process.cwd()`.
67+
- **Options**
68+
- `title` - process title description, use for kill grep.

lib/cmd/start.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class StartCommand extends Command {
1919

2020
this.options = {
2121
title: {
22-
description: 'process title description, use for kill grep, default to `egg-server-APPNAME`',
22+
description: 'process title description, use for kill grep, default to `egg-server-${APP_NAME}`',
2323
type: 'string',
2424
},
2525
workers: {
@@ -122,7 +122,6 @@ class StartCommand extends Command {
122122
argv.daemon = undefined;
123123

124124
const options = {
125-
cwd: baseDir,
126125
execArgv: context.execArgv,
127126
env,
128127
stdio: 'inherit',

lib/cmd/stop.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@ class StopCommand extends Command {
88

99
constructor(rawArgv) {
1010
super(rawArgv);
11-
this.usage = 'Usage: egg-scripts stop [baseDir]';
11+
this.usage = 'Usage: egg-scripts stop [--title=example]';
1212
this.serverBin = path.join(__dirname, '../start-cluster');
13+
this.options = {
14+
title: {
15+
description: 'process title description, use for kill grep',
16+
type: 'string',
17+
},
18+
};
1319
}
1420

1521
get description() {
@@ -25,19 +31,14 @@ class StopCommand extends Command {
2531

2632
const { argv } = context;
2733

28-
// egg-script stop
29-
// egg-script stop ./server
30-
// egg-script stop /opt/app
31-
let baseDir = argv._[0] || context.cwd;
32-
if (!path.isAbsolute(baseDir)) baseDir = path.join(context.cwd, baseDir);
33-
argv.baseDir = baseDir;
34-
35-
this.logger.info(`stopping egg application at ${baseDir}`);
34+
this.logger.info(`stopping egg application ${argv.title ? `with --title=${argv.title}` : ''}`);
3635

3736
// node /Users/tz/Workspaces/eggjs/egg-scripts/lib/start-cluster {"title":"egg-server","workers":4,"port":7001,"baseDir":"/Users/tz/Workspaces/eggjs/test/showcase","framework":"/Users/tz/Workspaces/eggjs/test/showcase/node_modules/egg"}
3837
let processList = yield this.helper.findNodeProcess(item => {
3938
const cmd = item.cmd;
40-
return cmd.includes('start-cluster');
39+
return argv.title ?
40+
cmd.includes('start-cluster') && cmd.includes(`"title":"${argv.title}"`) :
41+
cmd.includes('start-cluster');
4142
});
4243
let pids = processList.map(x => x.pid);
4344

@@ -55,7 +56,9 @@ class StopCommand extends Command {
5556
// node /Users/tz/Workspaces/eggjs/test/showcase/node_modules/[email protected]@egg-cluster/lib/app_worker.js {"framework":"/Users/tz/Workspaces/eggjs/test/showcase/node_modules/egg","baseDir":"/Users/tz/Workspaces/eggjs/test/showcase","port":7001,"workers":2,"plugins":null,"https":false,"key":"","cert":"","title":"egg-server","clusterPort":52406}
5657
processList = yield this.helper.findNodeProcess(item => {
5758
const cmd = item.cmd;
58-
return cmd.includes('egg-cluster/lib/app_worker.js') || cmd.includes('egg-cluster/lib/agent_worker.js');
59+
return argv.title ?
60+
(cmd.includes('egg-cluster/lib/app_worker.js') || cmd.includes('egg-cluster/lib/agent_worker.js')) && cmd.includes(`"title":"${argv.title}"`) :
61+
(cmd.includes('egg-cluster/lib/app_worker.js') || cmd.includes('egg-cluster/lib/agent_worker.js'));
5962
});
6063
pids = processList.map(x => x.pid);
6164

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "egg-scripts",
3-
"version": "2.1.1",
3+
"version": "2.3.0",
44
"description": "deploy tool for egg project",
55
"main": "index.js",
66
"bin": {
@@ -9,24 +9,24 @@
99
},
1010
"dependencies": {
1111
"common-bin": "^2.7.1",
12-
"egg-utils": "^2.2.0",
13-
"moment": "^2.19.1",
12+
"egg-utils": "^2.3.0",
13+
"moment": "^2.19.2",
1414
"mz": "^2.7.0",
1515
"mz-modules": "^2.0.0",
1616
"node-homedir": "^1.1.0",
1717
"runscript": "^1.3.0",
1818
"zlogger": "^1.1.0"
1919
},
2020
"devDependencies": {
21-
"autod": "^2.10.1",
21+
"autod": "^3.0.1",
2222
"coffee": "^4.1.0",
23-
"egg": "^1.9.0",
23+
"egg": "^1.11.0",
2424
"egg-bin": "^4.3.5",
2525
"egg-ci": "^1.8.0",
26-
"eslint": "^4.8.0",
26+
"eslint": "^4.11.0",
2727
"eslint-config-egg": "^5.1.1",
2828
"mm": "^2.2.0",
29-
"urllib": "^2.25.0",
29+
"urllib": "^2.25.1",
3030
"webstorm-disable-index": "^1.2.0"
3131
},
3232
"engines": {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
3+
module.exports = app => {
4+
app.get('/', function* () {
5+
this.body = `hi, ${app.config.framework || 'egg'}`;
6+
});
7+
8+
app.get('/env', function* () {
9+
this.body = app.config.env + ', ' + app.config.pre;
10+
});
11+
12+
app.get('/path', function* () {
13+
this.body = process.env.PATH;
14+
});
15+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'use strict';
2+
3+
exports.keys = '123456';
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name": "base-dir"
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name": "subdir-as-basedir"
3+
}

test/start.test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,34 @@ describe('test/start.test.js', () => {
335335
assert(result.data.toString() === 'hi, egg');
336336
});
337337
});
338+
339+
describe('subDir as baseDir', () => {
340+
let app;
341+
const rootDir = path.join(__dirname, '..');
342+
const subDir = path.join(__dirname, 'fixtures/subdir-as-basedir/base-dir');
343+
344+
before(function* () {
345+
yield utils.cleanup(rootDir);
346+
});
347+
348+
after(function* () {
349+
app.proc.kill('SIGTERM');
350+
yield utils.cleanup(rootDir);
351+
});
352+
353+
it('should start', function* () {
354+
app = coffee.fork(eggBin, [ 'start', '--workers=2', subDir ], { cwd: rootDir });
355+
// app.debug();
356+
app.expect('code', 0);
357+
358+
yield sleep(waitTime);
359+
360+
assert(app.stderr === '');
361+
assert(app.stdout.match(/egg started on http:\/\/127\.0\.0\.1:7001/));
362+
const result = yield httpclient.request('http://127.0.0.1:7001');
363+
assert(result.data.toString() === 'hi, egg');
364+
});
365+
});
338366
});
339367

340368
describe('start with daemon', () => {

0 commit comments

Comments
 (0)