簡體   English   中英

`rails server puma`與`puma`

[英]`rails server puma` vs. `puma`

一些指南( 示例 )建議您啟動一個網絡服務器

bundle exec rails server puma

但我總是直接用puma啟動服務器

bundle exec puma

通過rails server啟動puma(或任何其他服務器)時會發生什么特別的事情嗎?

使用rails s <server> ,將從Rails命令啟動服務器並了解Rails環境。

例如,這可以使用rails server command提供的任何功能和標志。

rails s --help
Usage: rails server [mongrel, thin, etc] [options]
    -p, --port=port                  Runs Rails on the specified port.
                                     Default: 3000
    -b, --binding=ip                 Binds Rails to the specified ip.
                                     Default: 0.0.0.0
    -c, --config=file                Use custom rackup configuration file
    -d, --daemon                     Make server run as a Daemon.
    -u, --debugger                   Enable ruby-debugging for the server.
    -e, --environment=name           Specifies the environment to run this server under (test/development/production).
                                     Default: development
    -P, --pid=pid                    Specifies the PID file.
                                     Default: tmp/pids/server.pid

    -h, --help                       Show this help message.

例如,您可以將調試器附加到傳遞--debugger或daemonize服務器的會話。

第二個優點是您可以對Puma實例進行版本控制,因為您必須在Gemfile列出gem。 如果您像使用bundle exec一樣啟動它,那么這已經成立了。

相反,當你只是運行$ puma (或$ bundle exec puma )時,你並沒有通過Rails系統。 Puma將嘗試找到一個機架引導程序文件並將使用它(它的工作原理是因為Rails在應用程序根目錄中提供了config.ru腳本。

一般來說,如果您不需要將特定選項傳遞給服務器,則沒有實際區別。 我喜歡puma,我傾向於在某些項目中使用它,即使在生產時我們使用Unicorn,因此運行$ puma作為獨立命令很方便,因為我不需要將它添加到Gemfile

但是,如果我的整個堆棧使用Puma ,我可能會使用$ rails s puma 這也是文檔中建議命令

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM