Closed logzh closed 5 years ago
@logzh 可以参考 egg-script start --workers=1 https://github.com/eggjs/egg-scripts#command, 不知道是不是这个
@LuoShiXi
参考:https://github.com/eggjs/egg/issues/3180
egg.js 2.15.0 开始增加的功能:support single process mode
// index.js
const egg = require('egg');
egg. start({
baseDir: __dirname,
});
执行命令:
node index.js
不过还不能用在生产环境,有warn提示:
single process mode is still in experiment, please don\'t use it in production environment
使用node index.js 成功跑起来,也输出了提示single process mode is still in experiment, please don\'t use it in production environment 然后eggcore egg logger mongoose security也都起来了
但是并没有端口可以访问到该服务?
const egg = require('egg');
egg. start({
baseDir: __dirname,
});
node index.js
搜遍全网,终于解决了。 这里记录一下阿里云Severless(CustomRuntime) + Nas的调用方式:
boostrap(需要可执行权限)
#!/bin/bash path=/mnt/**/alpha/ # `**`内填写函数计算服务绑定的Nas地址 export EGG_HOME=$path # 一定要写这个环境变量, 否则会报错 export EGG_SERVER_ENV=alpha # 指定env node $path/index.js
index.js
'use strict'; const egg = require('egg');
egg.startCluster({ baseDir: __dirname, mode: 'single', port: 9000 })
'use strict';
const egg = require('egg');
const main = async () => {
const app = await egg.start({
baseDir: __dirname,
});
app.listen(7001); // 端口
console.log(`Server started on ${7001}`);
};
main();
eggjs 2.15.0 + 增加了单进程模式支持,请问具体怎么以单进程方式启动?有文档吗?
相关环境信息