如何修复“错误:必须在环境中设置 MONGO_URL"?在 ubuntu 上使用永远和启动脚本? [英] How do I fix "Error: MONGO_URL must be set in environment" on ubuntu using forever and startup script?
问题描述
我刚刚在 EC2 ubuntu 服务器上部署了一个流星 js 应用程序.我安装了永远并将以下启动脚本添加到/etc/init/meteor.conf
I just deployed a meteor js app on an EC2 ubuntu server. I installed forever and added the following startup script to /etc/init/meteor.conf
start on (local-filesystems)
stop on shutdown
script
cd /home/ubuntu
export PORT=80 MONGO_URL=mongodb://localhost27017/parties ROOT_URL=http://ec2-54-235-1-185.compute-1.amazonaws.com
exec forever start bundle/main.js
end script
当我使用以下命令启动我的应用程序时:sudo servicemete start
,它显示为:
When I go to start my app using: sudo service meteor start
, it reads:
meteor start/running, process 12481
ubuntu@ip-10-98-57-161:~$
但是当我在浏览器中输入公共 DNS 时,什么也没有.
But when I enter the public DNS in my browser, nothing.
然后我输入命令forever list
,它列出了包含一些信息的三行和一列日志文件.所以我然后在 vim 中打开最后一个日志文件来查看它的内容,我看到了以下错误:
So I then type the command forever list
and it list three rows with some information and a column for log files. So I then open the last log file in vim to see it's contents and I'm seeing the following error:
/home/ubuntu/bundle/programs/server/boot.js:184
}).run();
^
Error: MONGO_URL must be set in environment
at Object.<anonymous> (packages/mongo-livedata/remote_collection_driver.js:32)
at Object._.once [as defaultRemoteCollectionDriver] (packages/underscore/underscore.js:704)
at new Meteor.Collection (packages/mongo-livedata/collection.js:66)
at packages/service-configuration/service_configuration_common.js:8
at packages/service-configuration.js:43:4
at packages/service-configuration.js:52:3
at mains (/home/ubuntu/bundle/programs/server/boot.js:153:10)
at Array.forEach (native)
at Function._.each._.forEach (/home/ubuntu/bundle/programs/server/node_modules/underscore/underscore.js:79:11)
at /home/ubuntu/bundle/programs/server/boot.js:80:5
error: Forever detected script exited with code: 1
我尝试了大约十种不同的方式来启动应用程序,但每次都遇到相同的错误.值得一提的一件事:当我运行我的应用程序时:
I've tried about ten different ways of starting the app and everytime I get the same error. One thing worth mentioning: When I run my app using:
sudo PORT=80 MONGO_URL=mongodb://localhost:27017/parties ROOT_URL=http://ec2-54-235-1-185.compute-1.amazonaws.com node bundle/main.js
它启动了,我可以通过我的公共 DNS 访问它,但是当然,一旦我关闭我的终端应用程序就会死亡.
It starts up, and I can access it through my public DNS, but of course, as soon as I close my terminal the app dies.
有人知道我该如何解决这个问题吗?
Does anybody know how I can fix this?
推荐答案
在我看来,您好像忘记了 mongourl 中的冒号 ´:´
it looks to me as if you forgot the colon ´:´ in your mongourl
export PORT=80 MONGO_URL=mongodb://localhost:27017/parties ROOT_URL=http://ec2-54-235-1-185.compute-1.amazonaws.com
你试过了吗?
这篇关于如何修复“错误:必须在环境中设置 MONGO_URL"?在 ubuntu 上使用永远和启动脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!