Làm thế nào để bạn thiết lập các biến môi trường để có được chạy meteorjs mãi mãi? Nếu tôi làm một xuất khẩu và chạy mãi mãi, như vậyLàm thế nào để thiết lập biến môi trường để có được thiên thạch chạy mãi mãi
export PORT=80 MONGO_URL=mongodb://localhost:3002/appname
sudo forever -f start bundle/main.js
mãi mãi sẽ không chạy meteorjs bó với nút:
/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
Nếu tôi chạy nó trực tiếp, nó chạy rất tốt:
sudo PORT=80 MONGO_URL=mongodb://localhost:3002/appname ROOT_URL=http://myapp.com node bundle/main.js
Nếu tôi làm điều đó như trong this answer nó hoạt động. Nhưng tại sao nó không hoạt động với câu lệnh export? Có cách nào để nói mãi mãi một tệp cấu hình để đọc các cài đặt đó không? Tôi không thấy cách nào trong số forever docs.
Lý do không hoạt động là các biến môi trường không được kế thừa sudo thừa hưởng. Kiểm tra người đàn ông sudo hoặc có một cái nhìn [ở đây] (http://unix.stackexchange.com/questions/16084/what-environment-do-i-get-with-sudo). – ruquay