【发布时间】:2015-02-04 17:15:35
【问题描述】:
我可以使用 VPS 或部署到 PaaS,但我决定让 Huginn 在我的 Webfaction 帐户上工作,因为我很确定这是可能的,而且我只是没有得到 rails 部署。
经过数小时的破解,我最终得到了一个正在运行的应用程序whose Agents do nothing。我无法运行foreman start,这个应该可以解决问题的神奇命令,所以我不知道还能做什么。
我是怎么到这里的
我习惯了 PHP,这些部署对我来说是陌生的,所以我确定问题出在椅子和键盘之间...
- 使用 Rails 4.1.8 (nginx 1.6.2/Passenger 4.0.53/Ruby 2.1.2) 创建了一个名为
huginn的新 Webfaction 应用程序。 - 将huginn 克隆到Webfaction 初始化的
hello_world示例应用程序旁边的自己的文件夹中。 (~/webapps/huginn/huginn/) - 编辑
~/webapps/nginx/conf/nginx.conf(来自Webfaction 的初始化脚本)指向我克隆的huginn文件夹而不是hello_world。将GEM_HOME更改为/home/foo/webapps/huginn/huginn/gems,而不是/home/foo/webapps/huginn/gems,将root更改为/home/foo/webapps/huginn/huginn/public,将rails_env更改为production。 - 编辑
~/webapps/huginn/bin/start以调整路径(见下文)。 - 正确复制并配置了 Huginn 的
.env,指向具有有效凭据的新 MySQL 数据库。添加了一个随机生成的APP_SECRET_TOKEN,设置主机名和邮箱配置。 - 使用 Webfaction's instructions 将应用程序 bin、路径和 gem 添加到 PATH。
- 从
~/webapps/huginn/huginn,运行gem2.1 install bundle,ruby2.1 bin/bundle,ruby2.1 bin/bundle exec rake db:migrate,ruby2.1 bin/bundle exec rake db:seed,一切顺利;安装到 huginn 的目录、填充的数据库等的依赖项。 - 运行
ruby2.1 bin/bundle exec foreman start并失败:
16:50:03 web.1 |从 pid 7115 开始
16:50:03 工作.1 |从 pid 7116 开始
16:50:06 工作。1 | /home/foo/webapps/huginn/huginn/gems/gems/spring-1.1.3/lib/spring/server.rb:22:in `initialize': Permission denied @ rb_sysopen - /tmp/spring/e89e6bd5b6863aeed0fbb5c861b1fc2d.pid ( Errno::EACCES)
- 返回并运行
~/webapps/huginn/bin/stop、~/webapps/huginn/bin/start,应用程序奇迹般地开始在我的浏览器中运行。除了代理,它们不按计划执行任何操作或尝试手动运行它们。
我怀疑在环境变量和 ruby 版本方面我遗漏了一些东西。有各种 ruby 版本可用,但 ruby --version 输出 ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux]。即使我发现有不同版本的符号链接,所以ruby2.1 --version 让我得到ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]。我的猜测是该应用程序使用的是 Ruby 1.8.7,我尝试使用该程序运行 install rvm to select a different ruby version——我没有通过 rvm install X.X.X,因为我不是 sudoer 并且无法安装 libyaml-devel。
得知我可以从已部署的应用目录运行 ruby2.1 bin/rails s --port=22766 --environment=production 并让该应用再次在浏览器中运行时,我感到非常兴奋——但遇到了完全相同的无响应代理问题。
看起来我真的很接近,但我错过了一些一直让 Huginn 的特工瘫痪的东西。 我错过了什么?
nginx.conf
env GEM_HOME=/home/foo/webapps/huginn/huginn/gems;
worker_processes 1;
events {
worker_connections 1024;
}
http {
access_log /home/foo/logs/user/access_huginn.log combined;
error_log /home/foo/logs/user/error_huginn.log crit;
include mime.types;
passenger_root /home/foo/webapps/huginn/gems/gems/passenger-4.0.53;
passenger_ruby /home/foo/webapps/huginn/bin/ruby;
sendfile on;
passenger_max_instances_per_app 1;
rails_spawn_method conservative;
passenger_max_pool_size 2;
server {
listen 22766;
passenger_enabled on;
root /home/foo/webapps/huginn/huginn/public;
server_name localhost;
rails_env production;
}
}
~/webapps/huginn/bin/start
#!/bin/bash
PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/foo/bin RUBYLIB=/home/foo/webapps/huginn/huginn/lib:$RUBYLIB TMPDIR=/home/foo/webapps/huginn/tmp PASSENGER_TMPDIR=/home/foo/webapps/huginn/tmp GEM_HOME=/home/foo/webapps/huginn/huginn/gems /home/foo/webapps/huginn/nginx/sbin/nginx -p /home/foo/webapps/huginn/nginx/
【问题讨论】:
标签: ruby-on-rails ruby web-deployment webfaction