简体   繁体   English

通过systemd套接字激活来启动Ruby on Rails应用程序(即,启动Rails服务器监听预先存在的套接字)

[英]Start Ruby on Rails app through systemd socket activation (i.e. start Rails server listening on pre-existing socket)

As the title states, I'm trying to start a Ruby on Rails app through systemd socket activation. 如标题所示,我正在尝试通过systemd套接字激活来启动Ruby on Rails应用。 I've no prior experience with Ruby and the lack of quality documentation is frustrating. 我以前没有使用Ruby的经验,并且缺乏质量文档令人沮丧。

Obtaining the listen socket from systemd is trivial enough, though I'm struggling to put that socket to use. 从systemd获得listen套接字很简单,尽管我正在努力使用该套接字。 Is there an app server, that accepts a pre-existing listen socket? 是否有一个接受预先存在的侦听套接字的应用服务器? Or do I have to write my own, possibly by implementing a Rack::Handler (going by what limited information I've been able to gather from the documentation)? 还是我必须写一个自己的,可能是通过实现一个Rack :: Handler(根据我能够从文档中收集到的有限信息来完成)? In the latter case a minimal example implementation would be helpful. 在后一种情况下,最少的示例实现会有所帮助。

I'm looking for a production-suitable, lightweight, least-effort solution, capable of serving an average of 2 concurrent users on embedded hardware. 我正在寻找一种适合生产,轻便,省力的解决方案,该解决方案能够平均为2位嵌入式硬件上的并发用户提供服务。

Starting with Puma 3.0.0, socket activation is supported by its Rack module, which is used by rails server . 从Puma 3.0.0开始,其Rack模块支持套接字激活,该模块由rails server This means that running bin/rails server puma from systemd with socket activation will now work out of the box (tested with Puma 3.9.1). 这意味着通过套接字激活从systemd运行bin/rails server puma现在将立即可用(已通过Puma 3.9.1测试)。 One caveat is that you must start bin/rails inside your application root, not the globally installed version. 一个警告是您必须在应用程序根目录(而不是全局安装的版本)中启动bin/rails

For more details on this setup and some examples, see my blogpost . 有关此设置的更多详细信息和一些示例,请参阅我的博客文章

In absence of any alternatives, I'll likely end up using the Puma web server, which implements the systemd socket activation protocol . 在没有其他选择的情况下,我可能最终会使用Puma Web服务器, 服务器实现了systemd套接字激活协议

EDIT: Puma does implement socket activation, but not in the Rack handler. 编辑:Puma确实实现了套接字激活,但是没有在Rack处理程序中实现。 I arrived at my initial conclusion via grep -r LISTEN_FDS and only discovered my mistake once I actually tried it. 我通过grep -r LISTEN_FDS得出了最初的结论,并且只有在实际尝试后才发现我的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Rails 3 Server在启动时崩溃:“不是套接字文件描述符” - Rails 3 Server crashes on start: “Not a socket file descriptor” 我应该如何启动这个Ruby on Rails应用程序? - How should I start this Ruby on Rails app? 启动Rails应用程序时如何启动ruby服务器脚本? - How can I start up a ruby server script when I start up my rails app? 带有新Rails应用程序的现有数据库 - Pre-existing database with new rails application 无法在 Rails 上启动服务器 Ruby - Cannot start server Ruby on Rails Ruby on Rails使用预先存在的数据库。 Rails使一切变得复数 - Ruby on Rails working with pre-existing database. Rails makes everything plural 无法启动Rails Server-'rails s'在现有应用程序内创建一个新的Rails应用程序 - Could Not start Rails Server - 'rails s' creates a new rails app inside existing app 无法通过套接字连接到本地MySQL服务器:我迷路了[Rails App] - Can't connect to local MySQL server through socket: I'm lost [Rails App] Ruby on Rails:更新为破坏我模型的现有属性的宝石吗? - Ruby on Rails: Update to a gem clobbering my model's pre-existing attribute, options? 在Rails应用程序中使用mongodb备份中的数据…即使用ruby将BSON转换为JSON? - Use data from mongodb backup in rails app… i.e. convert BSON to JSON using ruby?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM