当使用webapp.connecthandlers时,mup部署错误

我试图实现301redirect时访问我的“www”url重新路由到“非www”。 redirect在本地主机上工作,项目生成良好。 当我尝试部署与MUP,我得到这个错误:

x Invoking deployment process: FAILED -----------------------------------STDERR----------------------------------- :callback' will be initialized after [-Wreorder] v8::Handle<v8::Function> callback; ^ ../src/heap_output_stream.h:26:29: warning: 'v8::Handle<v8::Value> nodex::OutputStreamAdapter::abort' [-Wreorder] v8::Handle<v8::Value> abort; ^ ../src/heap_output_stream.h:11:7: warning: when initialized here [-Wreorder] OutputStreamAdapter( ^ gyp info ok npm WARN package.json meteor-dev-bundle@0.0.0 No description npm WARN package.json meteor-dev-bundle@0.0.0 No repository field. npm WARN package.json meteor-dev-bundle@0.0.0 No README data % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (7) Failed to connect to localhost port 80: Connection refused Latest deployment failed! Reverted back to the previous version. 

这里是有问题的代码。 当我删除它时,mup工作正常。 这个代码居住在/lib/_reroute-non-www.js

 if( Meteor.isServer ){ WebApp.connectHandlers.use(function(req, res, next){ if( req.headers.host == 'www.example.com' ){ res.writeHead(301, { Location: 'https://example.com' }) res.end() } else { next() } }) } 

这是什么意思呢?

虽然我不完全确定为什么这个特定的代码会导致mup这样“抛出”,但我确实发现了其他可能相关的原因。

当使用RabbitMQ(通过Wascally ),我的消费者处理程序必须通过使用注册

 Fiber(()=>{ rabbit.handle(key, consumerFn) }).run() 

…和里面consumeFn()我没有可用的meteor环境! 没有Meteor ,我没有权限访问我的应用程序中可能已经定义的任何集合。

我能够做的是使用Meteor.bindEnvironment当我注册处理程序时返回的承诺的处理程序。 使用Meteor.bindEnvironment使我可以访问Meteor应用程序中所有我想要的东西。

 Wascally.request(key, {content: 'my content'}) .then(Meteor.bindEnvironment((result)=>{ // now i have access to my Meteor environment and all collections }))