简体   繁体   English

Capistrano的Rails部署失败

[英]Rails deployment with Capistrano failing

I'm pretty new to RoR and deploying apps like these into production, so I've been doing quite a bit of reading. 对于RoR来说,我还很陌生,并将此类应用程序部署到生产环境中,所以我已经做了很多阅读工作。

There's one problem I can't seem to get past however. 但是,有一个我似乎无法克服的问题。 During my investigation, I came upon a thread on SO that indicates the behavior of Capistrano v3.x changed, which has confused some people. 在调查期间,我遇到了关于SO的线程,该线程指示Capistrano v3.x的行为已更改,这使一些人感到困惑。

One thing the thread detailed to do, was implement a remote file check, and if it doesn't exist during deployment, declare the local file to upload (which is my interpretation). 详细介绍的线程要做的一件事是实现远程文件检查,如果部署期间不存在该文件,则声明要上传的本地文件(这是我的解释)。

The following was added into my config/deploy.rb: 以下内容已添加到我的config / deploy.rb中:

namespace :deploy do
  namespace :check do
    task :linked_files => 'config/database.yml'
  end
  remote_file 'config/database.yml' => '/home/ubuntu/workspace/config/database.yml'
...
end

I'm working within Cloud9 IDE. 我正在Cloud9 IDE中工作。 When I run the cap production deploy command, the following excerpt from the deployment log is returned: 当我运行cap production deploy命令时,返回以下来自部署日志的摘录:

INFO [5cccd59b] Running /usr/bin/env mkdir -pv /home/deploy/--------/shared/config as deploy@---------------.com
DEBUG [5cccd59b] Command: /usr/bin/env mkdir -pv /home/deploy/--------/shared/config
INFO [5cccd59b] Finished in 0.068 seconds with exit status 0 (successful).
DEBUG [bd9797ee] Running /usr/bin/env [ -f /home/deploy/--------/shared/deploy:config/database.yml ] as deploy@---------------.com
DEBUG [bd9797ee] Command: [ -f /home/deploy/--------/shared/deploy:config/database.yml ]
DEBUG [bd9797ee] Finished in 0.067 seconds with exit status 1 (failed).
INFO Uploading /home/ubuntu/workspace/config/database.yml to /home/deploy/--------/shared/deploy:config/database.yml
DEBUG Uploading /home/deploy/--------/shared/deploy:config/database.yml 0.0%
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@---------------.com: scp: /home/deploy/--------/shared/deploy:config/database.yml: No such file or directory

I don't know 100%, but it seems to me that the path that it's auto inserting with the : is throwing off the script. 我不知道100%,但是在我看来,它自动使用:插入的路径正在抛出脚本。

Any guidance is appreciated! 任何指导表示赞赏!

Thanks in advance, 提前致谢,

Gabrial Gabrial

You're missing a database.yml file in your shared directory. 您在共享目录中丢失了database.yml文件。 Also, it's worth noting that if you've been working in a development environment, you'll have to configure the database.yml file for production as well. 另外,值得注意的是,如果您一直在开发环境中工作,则还必须配置database.yml文件进行生产。 Check to make sure *yml isn't listed in your .gitignore file. 检查以确保* yml未在您的.gitignore文件中列出。

Here's an example production entry: 这是一个示例生产条目:

production:
  adapter: mysql2
  database: production_for_my_app
  username: root
  password: ''
  host: localhost

Although you may have a database.yml file checked into version control, you need to have one in the shared directory outside of the app in your case. 尽管您可能已将一个database.yml文件签入版本控制,但您需要在应用程序外部的共享目录中保存一个。

To do this, SSH into your box 为此,将SSH连接到您的机器中

cd /home/rails/< your app >/shared/config

Then make the database.yml file 然后制作database.yml文件

touch database.yml

nano database.yml

Then copy and paste the contents of the copy of database.yml that you have in version control into the database.yml file you just created. 然后将您在版本控制中拥有的database.yml副本的内容复制并粘贴到刚创建的database.yml文件中。

Save the file and you're in business. 保存文件即可开展业务。

You should call remote_file without any namespaces. 您应该在没有任何名称空间的情况下调用remote_file

namespace :deploy do
  namespace :check do
    task :linked_files => 'config/database.yml'
  end
...
end

remote_file 'config/database.yml' => '/home/ubuntu/workspace/config/database.yml'

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM