简体   繁体   中英

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.

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.

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:

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. When I run the cap production deploy command, the following excerpt from the deployment log is returned:

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.

Any guidance is appreciated!

Thanks in advance,

Gabrial

You're missing a database.yml file in your shared directory. 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. Check to make sure *yml isn't listed in your .gitignore file.

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.

To do this, SSH into your box

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

Then make the database.yml file

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.

Save the file and you're in business.

You should call remote_file without any namespaces.

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'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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