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做项目似乎有效的work只有一个 #3578

Closed
1 task
huyu1 opened this issue Apr 1, 2019 · 15 comments · Fixed by eggjs/egg-bin#127
Closed
1 task

egg做项目似乎有效的work只有一个 #3578

huyu1 opened this issue Apr 1, 2019 · 15 comments · Fixed by eggjs/egg-bin#127
Assignees

Comments

@huyu1
Copy link

huyu1 commented Apr 1, 2019

  • I have searched the issues of this repository and believe that this is not a duplicate.

Environment

Reproduction

使用egg-init egg-example --type=simple快速构建项目
在package.json修改"dev": "egg-bin dev --workers=7",
设置all的定时器,schedule/consoleDate.js,
理论上应该所有的work都打印这个,但是似乎就一个work打印,其他work处于不工作状态
只打印出了一个进程pid

@atian25
Copy link
Member

atian25 commented Apr 1, 2019

不需要重新开一个的,下次直接在原来 issue 回复即可。

看了下,目前 egg-bin dev 不支持 --workers,你可以用 -c=7

具体参见源码: https://github.com/eggjs/egg-bin/blob/master/lib/cmd/dev.js

我等会加个 workers 的支持。

@huyu1
Copy link
Author

huyu1 commented Apr 1, 2019

但是不加works=7的时候,还是只打印出了一个work的pid,我的电脑是4核

@atian25
Copy link
Member

atian25 commented Apr 1, 2019

dev 是本地开发,只会默认开一个 worker。正式使用你应该用 egg-scripts,请阅读相关部署文档。

@huyu1
Copy link
Author

huyu1 commented Apr 1, 2019

好的,谢谢,我明白了

@huyu1
Copy link
Author

huyu1 commented Apr 1, 2019

我想问一下,启动自定义的app.js和多进程的app.js是同一个吗,看上去是同一个,但是这会不会有点怪异

@atian25
Copy link
Member

atian25 commented Apr 1, 2019

没看懂

@huyu1
Copy link
Author

huyu1 commented Apr 1, 2019

在教程中,框架提供了统一的入口文件(app.js)进行启动过程自定义,这个文件返回一个 Boot 类,我们可以通过定义 Boot 类中的生命周期方法来执行启动应用过程中的初始化工作。。。。。然后多进程中的work的入口也是app.js,都在跟目录下,是同一个吗

@atian25
Copy link
Member

atian25 commented Apr 1, 2019

当然是同一个啦,每一个进程都有自己的生命周期。

@huyu1
Copy link
Author

huyu1 commented Apr 1, 2019

我在学习egg-Sequelize的时候创建完.sequelizerc.js之后:::
:'use strict';

const path = require('path');

module.exports = {
config: path.join(__dirname, 'database/config.json'),
'migrations-path': path.join(__dirname, 'database/migrations'),
'seeders-path': path.join(__dirname, 'database/seeders'),
'models-path': path.join(__dirname, 'app/model'),
};

在执行npx sequelize init:config的时候,报错:
Unable to resolve sequelize package in F:\HBuilderProjects\cloubox_07\sequelize-project是怎么回事额

@atian25
Copy link
Member

atian25 commented Apr 1, 2019

不是写的很清楚么,没安装 sequelize 吧

@huyu1
Copy link
Author

huyu1 commented Apr 1, 2019

装了egg-sequelize,我跟着教程一步一步走,linux过了,win10下报错Unable to resolve sequelize package in F:\HBuilderProjects\cloubox_07\sequelize-project

@huyu1
Copy link
Author

huyu1 commented Apr 1, 2019

安装了cnpm install sequelize过了,egg-sequelize和sequelize不是一个东西吗,为什么linux下只安装egg-sequelize也不会报错

@atian25
Copy link
Member

atian25 commented Apr 1, 2019

egg-sequelize和sequelize不是一个东西吗

当然不是同一个类库啦。。。你是不是需要先去熟悉下 Node 和 NPM ?

那可能是因为扁平化安装后,根目录就有了子依赖。

@huyu1
Copy link
Author

huyu1 commented Apr 1, 2019

好吧,我以为egg-sequelize是你们把sequelize封装的版本

@atian25
Copy link
Member

atian25 commented Apr 1, 2019

跟主题不是一个问题了,如果你 sequelize 这个按教程走不通,那就重新发个 issue,提供最小化可复现仓库,以及对应的复现操作。

@atian25 atian25 closed this as completed Apr 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants