Skip to content

Instantly share code, notes, and snippets.

@atian25
Created February 28, 2017 01:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atian25/17ed254f73268abd38d6a1d0102d5eb3 to your computer and use it in GitHub Desktop.
Save atian25/17ed254f73268abd38d6a1d0102d5eb3 to your computer and use it in GitHub Desktop.
egg-scripts proposals #465 backup

eggjs/egg#241 太长了,重开一个,讨论第一期的实现方案。

仅提供 egg-scripts startegg-scripts stop 几条最基础的线上指令。 而看了下原内网的实现,会比较依赖于环境变量,本方案更倾向于用 cli options 的方式

start

$ egg-scripts start --baseDir=<APP_BASE> --port=7001 --env=prod --workers=2 --no-daemon

description :

进程的 process title 是否需要包含特殊关键词,用于 stop 脚本判断? master 进程上提供 --egg 关键词,用于 stop 脚本判断

应用本身无需提供 index.js,但 webstorm debug 的时候要看看怎么搞? webstorm 支持 debug npm scripts,传递一个参数即可

options :

baseDir 为应用的根目录,可选,默认为 process.cwd(),支持相对路径

customEgg 为框架的路径,可选,默认按照 egg-utils寻址方式

在 egg-cluster 里面做了, 这里不用传递了

  • 应用 pkg.egg.framework 中指定的框架名
  • 在应用 node_modules 目录下寻找继承于 egg 的上层框架
  • 使用 egg

port 为端口,可选,默认为 7001,不做冲突自动更换端口。

env 为运行环境,可选,默认为 prod

  • 大小写不敏感,内部会统一转换为小写
  • 环境变量取值顺序 env 传值 -> EGG_SERVER_ENV 环境变量 -> 默认值 prod

workers 配置 workers 个数,默认为 cpu 个数

no-daemon 配置该参数则在前台运行

stop

$ egg-scripts stop --baseDir=<APP_BASE>

description :

  • 找到指定目录下的 egg master 进程,并 kill 掉
  • 在 5s 后,寻找没有被 egg master 优雅退出的 worker/agent 进程,kill -9

options :

baseDir 为应用的根目录,可选,默认为 process.cwd()

list

不做该需求

$ egg-scripts list

说明:

  • 列出当前机器上运行的所有 egg master 进程

options :

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment