一些指南(示例)推荐这样做来启动one服务器
bundle exec rails server puma但是我总是直接用puma启动服务器
bundle exec puma当通过rails server触发美洲狮(或任何其他服务器)时,会发生什么特殊的事情吗?
发布于 2014-01-19 14:33:30
当您使用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或守护服务器的会话。
第二个优点是您可以对Puma实例进行版本化,因为您必须在Gemfile中列出gem。如果您像正在做的那样用bundle exec启动它,那么这已经是真的。
相反,当您只运行$ puma (或$ bundle exec puma)时,您不会通过Rails系统。Puma将尝试找到一个rack引导文件并使用它(因为Rails在应用程序根目录中提供了一个config.ru脚本)。
一般来说,如果不需要将特定选项传递给服务器,则没有真正的区别。我喜欢美洲狮,而且我倾向于在一些项目中使用它,即使在生产中我们使用Unicorn,因此将$ puma作为独立命令运行是很方便的,因为我不需要将它添加到Gemfile中。
但是,如果我的整个堆栈使用Puma,我可能会使用Puma。这也是在文档中建议的命令。
https://stackoverflow.com/questions/21213343
复制相似问题