Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set environment variables to get forever run meteorjs

How do you set the environment variables to get forever run meteorjs? If I do an export and run forever, like so

export PORT=80 MONGO_URL=mongodb://localhost:3002/appname

sudo forever -f start bundle/main.js

forever will not run the meteorjs bundle with node:

/Users/../bundle/server/server.js:166
throw new Error("MONGO_URL must be set in environment");
      ^
Error: MONGO_URL must be set in environment
at run (/Users/../bundle/server/server.js:166:11)
at Object.<anonymous> (/Users/../bundle/server/server.js:331:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/../bundle/main.js:1:63)
at Module._compile (module.js:456:26)
error: Forever detected script exited with code: 8

If I run it directly, it runs smoothly:

sudo PORT=80 MONGO_URL=mongodb://localhost:3002/appname ROOT_URL=http://myapp.com node bundle/main.js

If I do it like in this answer it works. But why doesn't it work with the export statement? Is there a way to tell forever a config file to read those settings? I don't see a way in the forever docs.

like image 545
happly Avatar asked Jun 03 '13 17:06

happly


1 Answers

You can run forever just like node. Try following

sudo PORT=80 MONGO_URL=mongodb://localhost:3002/appname ROOT_URL=http://myapp.com forever -f start bundle/main.js
like image 170
slv007 Avatar answered Nov 15 '22 08:11

slv007