Skip to content

Commit

Permalink
add server error report
Browse files Browse the repository at this point in the history
  • Loading branch information
kekee000 committed Nov 3, 2016
1 parent b4462a5 commit e251a94
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,35 @@ module.exports = {
};
```

![](./example/mip-init.png)

----
在当前项目创建一个mip模板网页:

``` bash
$ mip add index.html
```

![](./example/mip-add.png)

----
`mip-extensions`仓库中创建一个mip组件:

``` bash
$ mip addelement mip-demo
```

![](./example/mip-addelement.png)

----
验证mip网页:

``` bash
$ mip validate index.html [...]
```

![](./example/mip-validate.png)

----
在当前项目或者`mip-extensions`仓库中启动mip网页调试器:

Expand All @@ -103,6 +114,16 @@ $ mip server

配置了`mipmainDir`之后可以调试`mip`引擎。

`mip server` 启动多个实例的话会报端口占用错误,需要关闭其他实例或者kill掉占用端口的进程后再启动。

```
➜ ~ mip server
INFO livereload server start at: http://172.20.128.110:35730
ERROR PORT 8000 already in use, please retry again!
```

![](./example/mip-server.png)

----

直接从官方 npm registry 安装,可能会由于网络原因,导致安装时间较长或安装失败。此时我们可以选择速度更快的 registry。
Expand Down
Binary file added example/mip-add.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/mip-addelement.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/mip-init.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/mip-server.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/mip-validate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions lib/server-start.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ function startServer(config) {
cli.info('mip server start at:',
cli.chalk.green('http://' + ip + ':' + config.port)
);
})
.on('error', e => {
if (e.code === 'EADDRINUSE') {
cli.error(cli.chalk.yellow('PORT ' + config.port + ' already in use, please retry again!'));
process.exit();
}
else {
throw e;
}
});

// livereload配置
Expand All @@ -40,6 +49,15 @@ function startServer(config) {
],
delay: 500
});
lrServer.server.on('error', e => {
if (e.code === 'EADDRINUSE') {
cli.error(cli.chalk.yellow('PORT 35730 already in use, please retry again!'));
process.exit();
}
else {
throw e;
}
});

// 监听mip页面
let watches = [
Expand Down

0 comments on commit e251a94

Please sign in to comment.