使用分離的資料庫部署應用程式(MONGO URL)

你需要將應用程式層與資料庫層分開,這意味著指定 MONGO_URL。這意味著通過 bundle 命令執行你的應用程式,解壓縮它,設定環境變數,然後將專案作為節點應用程式啟動。這是如何做…

#make sure you're running the node v0.10.21 or later
npm cache clean -f
npm install -g n
sudo n 0.10.21

# bundle the app
mkdir myapp
cd myapp 
git clone http://github.com/myaccount/myapp
meteor bundle --directory ../deployPath
cd ../deployPath

# make sure fibers is installed, as per the README
export MONGO_URL='mongodb://127.0.0.1:27017/mydatabase'
export PORT='3000'
export ROOT_URL='http://myapp.com'

# run the site
node main.js