Joh*_*hir 6 ruby-on-rails heroku puma
一些指南(示例)建议您启动一个网络服务器
bundle exec rails server puma
Run Code Online (Sandbox Code Playgroud)
但我总是刚开始的服务器puma直接
bundle exec puma
Run Code Online (Sandbox Code Playgroud)
通过启动puma(或任何其他服务器)时会发生什么特别的事情rails server吗?
Sim*_*tti 11
使用时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.
Run Code Online (Sandbox Code Playgroud)
例如,您可以将调试器附加到传递--debugger或守护服务器的会话.
第二个优点是您可以对Puma实例进行版本控制,因为您必须在中列出gem Gemfile.如果你bundle exec像开始那样开始它已经是真的了.
相反,当您只是运行$ puma(或$ bundle exec puma)时,您没有通过Rails系统.Puma将尝试查找机架引导文件并将使用它(它的工作原理是因为Rails config.ru在应用程序根目录中提供了一个脚本.
一般来说,如果您不需要将特定选项传递给服务器,则没有实际区别.我喜欢puma,我倾向于在某些项目中使用它,即使在生产中我们使用Unicorn,因此$ puma作为独立命令运行是很方便的,因为我不需要将它添加到Gemfile.
但是,$ rails s puma如果我的整个堆栈使用,我可能会去Puma.这也是文档中建议的命令.
| 归档时间: |
|
| 查看次数: |
3425 次 |
| 最近记录: |