4

[Rails] 利用 pow 取代 localhost:3000 進行開發吧!

 2 years ago
source link: https://blog.niclin.tw/2017/07/23/rails-%E5%88%A9%E7%94%A8-pow-%E5%8F%96%E4%BB%A3-localhost3000-%E9%80%B2%E8%A1%8C%E9%96%8B%E7%99%BC%E5%90%A7/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

一般 Rails 開發久一些的工程師,都會對還要額外開一個 terminal 來跑 localhost:3000 這件事情來得厭煩

尤其容易遇到如果同時開發兩個專案以上,要不時的切換來切換去,或是在開一個port 來執行 rails s -p 3001 ,同時也會佔用一個 terminal ,並且也沒有一個容易記一些的域名,比方說 nic-repo.dev

Pow 這個玩意兒就是來解決這些工程師的困擾,當你訪問該開發用的 domain 時會直接啟動 server ,並且在預設的 timeout 過後會自動 kill server 運行。

也可以安裝相對應的 gem install powder,就可以直接執行重啟指令

powder restart

而不用原本的

touch tmp/restart.txt

Pow 安裝方法

進入 Pow 官方網站

依照說明,執行安裝指令

curl get.pow.cx | sh

接下來切換到 .pow 目錄

cd ~/.pow

然後對你想要做開發域名設定的專案做個 sync

ln -s /path/to/myapp

例如,我希望能訪問 nic-repo.dev 來進行開發我的 nic-repo 的話

ln -s ~/projects/nic-repo nic-repo

就可以順利訪問 http://nic-repo.dev 進行開發了哦

查看 log

Rails development log

tail -f log/development.log

powder

powder applog

##缺點:

使用 binding.pry 進行開發有些麻煩,需要安裝 pry-remote

並將原本用的 binding.pry 替換成 binding.remote_pry

然後在執行到中斷點的時候,於 terminal 裡輸入 pry-remote

來取得回應,並進行操作,不過 pry-remote 還是會常常遇到 lag、輸入點錯位、或是莫名斷線等問題,在這邊我的開發模式還是會在用到 binding.pry 時在開一個 rails server 起來就是了(聽起來有點蠢XD)


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK