安裝Linux的Client以及推上Heroku上
1. 安裝client工具
$ wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh
2. heroku login
$ heroku login
Enter your Heroku credentials.
Email: perry.wu0606@gmail.com
Password (typing will be hidden):
Authentication successful.
3. 到有git的app下建立連結
沒有git的就自己git 出來吧!
要確定該folder有Procfile這個檔案
$ cat Procfile
web: node index.js
$ heroku create
Creating fast-brook-1101... done, stack is cedar-14
https://fast-brook-1101.herokuapp.com/ | https://git.heroku.com/fast-brook-1101.git
Git remote heroku added
$ git remote -v
heroku https://git.heroku.com/fast-brook-1101.git (fetch)
heroku https://git.heroku.com/fast-brook-1101.git (push)
origin https://github.com/heroku/node-js-getting-started.git (fetch)
origin https://github.com/heroku/node-js-getting-started.git (push)
4. 推到heroku上執行
$ git push heroku master
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote:
remote: -----> Reading application state
remote: package.json...
remote: build directory...
remote: cache directory...
remote: environment variables...
remote:
remote: Node engine: 0.12.2
remote: Npm engine: unspecified
remote: Start mechanism: Procfile
remote: node_modules source: package.json
remote: node_modules cached: false
remote:
remote: NPM_CONFIG_PRODUCTION=true
remote: NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote: Downloading and installing node 0.12.2...
remote: Using default npm version: 2.7.4
remote:
remote: -----> Building dependencies
remote: Installing node modules
remote: express@4.9.8 node_modules/express
remote: ¢u¢w¢w utils-merge@1.0.0
remote: ¢u¢w¢w merge-descriptors@0.0.2
remote: ¢u¢w¢w fresh@0.2.4
remote: ¢u¢w¢w cookie@0.1.2
remote: ¢u¢w¢w escape-html@1.0.1
remote: ¢u¢w¢w range-parser@1.0.2
remote: ¢u¢w¢w cookie-signature@1.0.5
remote: ¢u¢w¢w finalhandler@0.2.0
remote: ¢u¢w¢w vary@1.0.0
remote: ¢u¢w¢w media-typer@0.3.0
remote: ¢u¢w¢w methods@1.1.0
remote: ¢u¢w¢w parseurl@1.3.0
remote: ¢u¢w¢w serve-static@1.6.5
remote: ¢u¢w¢w path-to-regexp@0.1.3
remote: ¢u¢w¢w depd@0.4.5
remote: ¢u¢w¢w qs@2.2.4
remote: ¢u¢w¢w on-finished@2.1.1 (ee-first@1.1.0)
remote: ¢u¢w¢w debug@2.0.0 (ms@0.6.2)
remote: ¢u¢w¢w etag@1.4.0 (crc@3.0.0)
remote: ¢u¢w¢w proxy-addr@1.0.8 (forwarded@0.1.0, ipaddr.js@1.0.1)
remote: ¢u¢w¢w send@0.9.3 (destroy@1.0.3, ms@0.6.2, mime@1.2.11, on-finished@2.1.0)
remote: ¢u¢w¢w type-is@1.5.7 (mime-types@2.0.12)
remote: ¢|¢w¢w accepts@1.1.4 (negotiator@0.4.9, mime-types@2.0.12)
remote:
remote: -----> Checking startup method
remote: Found Procfile
remote:
remote: -----> Finalizing build
remote: Creating runtime environment
remote: Exporting binary paths
remote: Cleaning npm artifacts
remote: Cleaning previous cache
remote: Caching results for future builds
remote:
remote: -----> Build succeeded!
remote:
remote: node-js-getting-started@0.1.3 /tmp/build_e36f0548cd7e9ef2a4f9015fd5e300e5
remote: ¢|¢w¢w express@4.9.8
remote:
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing... done, 9.3MB
remote: -----> Launching... done, v3
remote: https://fast-brook-1101.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/fast-brook-1101.git
* [new branch] master -> master
5. 連網頁測試
一推上後會看到訊息, 由訊息的連結就可以存取剛剛放上去的應用 https://fast-brook-1101.herokuapp.com/ 也可使用heroku apps:info來查詢連結資訊
要注意的是heroku會需要應用裡面有設定pro
其他指令
* 讓app只在web上佈署一台
$ heroku ps:scale web=1
Scaling dynos... done, now running web at 1:1X.
* To shutdown the app
$ heroku ps:scale web=0
* 看目前現有的app列表
heroku apps
heroku apps:info