Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Egg最新版本怎么添加入口启动文件 app.js, index.js? #5241

Open
pxim opened this issue Jul 21, 2023 · 2 comments
Open

Egg最新版本怎么添加入口启动文件 app.js, index.js? #5241

pxim opened this issue Jul 21, 2023 · 2 comments

Comments

@pxim
Copy link

pxim commented Jul 21, 2023

  1. Egg最新版本怎么添加入口启动文件 app.js, index.js这种。
  2. 我在配置pkg,或者 @vercel/ncc 需要一个入口文件
@dingiyan
Copy link
Contributor

可以自己创建一个入口文件,并在其中调用egg-scripts或者调用你主框架的start-cluster方法。具体代码可以百度,或研读egg-scripts的代码。相当于egg-scripts包封装了入口文件,项目直接执行命令就行,pkg的话入口文件就得自己手写一个去启动。

@sinkhaha
Copy link
Contributor

sinkhaha commented Dec 19, 2023

  1. 可以这样启动多进程模式,也是egg-scripts 默认的启动方式,options 参数可参考源码
const { startCluster } = require('egg');

const options = {
  title: 'test',
  workers: 1,
  baseDir: '项目路径',
  framework: 'egg库路径'
}

startCluster(options); 
  1. 也可以试试只启动app单进程模式
const { Application } = require('egg');

const app = new Application({
  mode: 'single',
});

app.listen(7001, '127.0.0.1', () => {
  console.log('server start on http://127.0.0.1:7001');
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants