從原本啟動 Rails server 、 Webpacker 外,後續增加了 Resque、Sidekiq ,變成要開四個視窗啟動,有時還會忘記要開其中一個...
這時可透過領班 (foreman) 解決此痛點,啟動一個抵全部 :-)
後續的文章會以此 repo 作為範例
放在 :development
中,可參考此 commit
# Gemfile
gem 'foreman', '~> 0.87.2'
# 記得要 bundle
接著在專案的目錄新增 Procfile
檔案,可參考此 commit
備註: 前面 web
、webpack
、resque
、sidekiq
名稱可自取
# Procfile
web: ./bin/rails s -p 3000
webpack: ./bin/webpack-dev-server
resque: QUEUE=* INTERVAL=1 rake resque:work
sidekiq: bundle exec sidekiq
# 方法1
foreman start
# 方法2
foreman s
# 只執行指定 PROCESS
foreman start [PROCESS]
# 範例
foreman start web
# 檔名不想取 Procfile,需指定檔案才能執行
foreman start -f file
# 範例 (檔名為 hello)
foreman start -f hello
foreman start
foreman -h
Commands:
foreman check # Validate your application's Procfile
foreman export FORMAT LOCATION # Export the application to another process management format
foreman help [COMMAND] # Describe available commands or one specific command
foreman run COMMAND [ARGS...] # Run a command using your application's environment
foreman start [PROCESS] # Start the application (or a specific PROCESS)
foreman version # Display Foreman gem version
Options:
-f, [--procfile=PROCFILE] # Default: Procfile
-d, [--root=ROOT] # Default: Procfile directory
Foreman 是蠻好用的工具,當有多個要啟動時,挺有感的,且突然忘記某個啟動指令怎輸入的話,還能看下 Procfile
檔案
鐵人賽文章連結:https://ithelp.ithome.com.tw/articles/10247491
medium 文章連結:https://link.medium.com/bWT6dLpueab
本文同步發布於 小菜的 Blog https://riverye.com/
備註:之後文章修改更新,以個人部落格為主