“我该如何解决?”;错误:MONGO“必须在环境中设置URL”;在ubuntu上使用永久和启动脚本?
我刚刚在EC2 ubuntu服务器上部署了meteor js应用程序。我安装了 并将以下启动脚本添加到/etc/init/meteor.conf“我该如何解决?”;错误:MONGO“必须在环境中设置URL”;在ubuntu上使用永久和启动脚本?,ubuntu,meteor,forever,startupscript,Ubuntu,Meteor,Forever,Startupscript,我刚刚在EC2 ubuntu服务器上部署了meteor js应用程序。我安装了 并将以下启动脚本添加到/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.
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 service meteor start
启动我的应用程序时,它会显示:
meteor start/running, process 12481
ubuntu@ip-10-98-57-161:~$
但当我在浏览器中输入公共DNS时,什么都没有
因此,我随后键入命令foreverlist
,它列出了三行信息和一列日志文件。因此,我在vim中打开最后一个日志文件,查看其内容,并看到以下错误:
/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
它启动了,我可以通过我的公共DNS访问它,但当然,一旦我关闭终端,应用程序就会死掉
有人知道我如何解决这个问题吗?在以下情况之前,请尝试在不使用导出的情况下将其传递到forever Stright:
exec PORT=80 MONGO_URL=mongodb://localhost27017/parties ROOT_URL=http://ec2-54-235-1-185.compute-1.amazonaws.com forever start bundle/main.js
这可能与权限有关,当使用启动脚本时,用户可能会有自己设置的变量范围。在我看来,您似乎忘记了mongourl中的冒号´:´
export PORT=80 MONGO_URL=mongodb://localhost:27017/parties ROOT_URL=http://ec2-54-235-1-185.compute-1.amazonaws.com
您试过了吗?和
localhost27017
是正确的主机/端口组合吗?它应该是localhost:27017
。
export PORT=80 MONGO_URL=mongodb://localhost:27017/parties ROOT_URL=http://ec2-54-235-1-185.compute-1.amazonaws.com