How do I fix "Error: MONGO_URL must be set in environment" on ubuntu using forever and startup script?

Scott picture Scott · Aug 21, 2013 · Viewed 11.8k times · Source

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

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:~$ 

But when I enter the public DNS in my browser, nothing.

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

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?

Answer

Micha Roon picture Micha Roon · Aug 24, 2013

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

have you tried that?