File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -17,19 +17,22 @@ module.exports = async function(api, info = {}) {
1717 }
1818 } ) ;
1919
20+ // 上下文参数
21+ const apiContext = api . context || { } ;
22+
2023 const { index, port, host } = info ;
2124 const runApp = require ( index ) ; // app.js
2225 await runApp ( app ) ;
2326
2427 const portfinder = require ( 'portfinder' ) ;
2528
26- const startPort = parseInt ( process . env . PORT || port || 3000 ) ;
29+ const startPort = parseInt ( process . env . PORT || apiContext . port || port || 3000 ) ;
2730 const _port = await portfinder . getPortPromise ( {
2831 port : startPort , // minimum port
2932 stopPort : startPort + 300 , // maximum port
3033 } ) ;
3134
32- const _host = process . env . HOST || host || '0.0.0.0' ;
35+ const _host = process . env . HOST || apiContext . host || host || '0.0.0.0' ;
3336
3437 return new Promise ( ( resolve , reject ) => {
3538 app . listen ( _port , _host , err => {
You can’t perform that action at this time.
0 commit comments