【发布时间】:2021-05-13 13:06:12
【问题描述】:
我正在尝试将 apache 设置为在 Rails Web 套接字上与乘客一起使用 ruby。我知道Passenger + Apache不支持Action Cable,所以我尝试使用反向代理解决方案: https://www.phusionpassenger.com/library/deploy/standalone/reverse_proxy.html
主应用程序应继续使用Passenger Apache 模块,而websocket 应使用Passenger Standalone。
我启用了反向代理并更改了虚拟主机配置。
<VirtualHost *:80>
...
PassengerRuby /home/rails/.rvm/gems/ruby-2.5.1/wrappers/ruby
<Location "/cable">
ProxyPass "ws://127.0.0.1:4000/cable"
ProxyPassReverse http://127.0.0.1:4000/
ProxyPreserveHost on
</Location>
...
</VirtualHost>
当我从命令行启动乘客时
bundle exec passenger start --daemonize --address 127.0.0.1 --port 4000
它工作正常,但是当我在 Ubuntu 18.04.5 LTS 中使用 systemd 创建服务时
...
[Service]
Type=forking
WorkingDirectory=/mnt/xfeature/srv/www/f3.xxxx.xxx/current
Environment=RAILS_ENV=feature
User=rails
Group=www-data
UMask=0002
ExecStart=/home/rails/.rvm/bin/rvm-shell -c 'bundle exec passenger start --daemonize -e feature --address 127.0.0.1 --port 4000 --log-level 5'
ExecStop=/home/rails/.rvm/bin/rvm-shell -c 'bundle exec passenger stop --port 4000'
....
它通常会因为这个错误而失败。
[ E 2021-05-13 09:52:13.3607 21447/Tz age/Cor/App/Implementation.cpp:221 ]: Could not spawn process for application /mnt/xfeature/srv/www/f3.xxx.xxx/releases/20210513094622: An operating system error occurred while preparing to start a preloader process: Cannot change the directory '/tmp/passenger.spawn.XXXXgMx55z/envdump' its UID to 1001 and GID to 1001: Operation not permitted (errno=1)
Error ID: 847da63a
Error details saved to: /tmp/passenger-error-5S5Syq.html
并且无法建立 websocket 连接。我检查了 /tmp 权限,一切正常。
有什么建议吗?
【问题讨论】:
标签: ruby-on-rails apache websocket passenger