1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
| # 切換到部署目錄中 cd deploy
# 複雜一份檔案到部署目錄裡頭 git clone ../labs/topic
# 進入需要部署的專案裡 cd topic
# 修改專案的描述檔 vim package.json
{ "private": true, "subdomain": "my.topic", "engines": { "node": "0.6.x" }, "scripts": { "start": "app.js" }, "name": "topic", "version": "0.1.0-7", // 當有更新時會變動 "dependencies": { "express": "2.5.11", "ejs": "0.8.3", "mongoose": "2.8.3", "connect-form": "0.2.1", "relative-date": "https://github.com/azer/relative-date/tarball/master" } } # 描述說明 - subdomain: 專案網址 (http://your-subdomain.jit.su) - engines.node: 使用的 node 版本 - scripts.start: 自動執行的預設檔案
# 安裝 nodejitsu 工具 npm install jitsu
# 查看使用說明 # (因我沒使用 -g 全域安裝,所以使用以下指令) node_modules/jitsu/bin/jitsu
# 登入到 nodejitsu node_modules/jitsu/bin/jitsu login
# 建立 MongoDB 資料庫,將結果中的資料放進程式 node_modules/jitsu/bin/jitsu databases create mongo
# 打開 app.js 修改 app.listen app.listen(process.env.PORT || 8080, function (err) { if (err) { throw err; }
console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env); });
# 部署到 nodejitsu 上面 node_modules/jitsu/bin/jitsu deploy
# 管理 MongoDB mongo SUBDOMAIN.mongohq.com:10004/DBNAME -u nodejitsu -p PASSWORD
|