A
A
akimdi2017-05-25 15:45:51
Ruby on Rails
akimdi, 2017-05-25 15:45:51

Unable to deploy to DigitalOcean with Capistrano?

I do according to this instruction, but nothing comes out.
At first it says that I don't have a symbolic link to the **database.yml** file on the server

00:03 deploy:check:linked_files
    ERROR linked file /home/demo/myproject/shared/config/database.yml does not exist on 188.226.140.17

I read that you need to manually create the file **database.yml**
I created it.
touch /home/demo/myproject/shared/config/database.yml
And entered the contents there:
spoiler
production:
      adapter: postgresql
      encoding: utf8
      database: myproject_db
      username: postgres
      password: 1234567890postgres
      host: localhost
      pool: 5
      min_messages: WARNING

Then he writes that there is no symbolic link to the **secrets.yml** file:
00:03 deploy:check:linked_files
          ERROR linked file /home/demo/myproject/shared/config/secrets.yml does not exist on 188.226.140.17

Created **secrets.yml** on the server
touch /home/demo/myproject/shared/config/secrets.yml

And the data transferred those that were in the project in the file **secrets.yml**
# Be sure to restart your server when you modify this file.
    
    # Your secret key is used for verifying the integrity of signed cookies.
    # If you change this key, all old signed cookies will become invalid!
    
    # Make sure the secret is at least 30 characters and all random,
    # no regular words or you'll be exposed to dictionary attacks.
    # You can use `rake secret` to generate a secure secret key.
    
    # Make sure the secrets in this file are kept private
    # if you're sharing your code publicly.
    
    development:
      secret_key_base: 1bbe19e548182eb986995dfef00bb0bb0ed410e25c8cdbf4e9f2e92290ce69f91b84c0fa76fdd50a18d49fea3906f57a0cba9398562fa39492a3472b680d8112
    
    test:
      secret_key_base: ed1b6e6ca1dfd6c1b939414ffd69fa92dadfeb61fe7e819ac7d08c515a169f8648ec29b21e89a34d8649585916b6485dfc74f9eded1ecf83a87e315500e1b64a
    
    # Do not keep production secrets in the repository,
    # instead read values from the environment.
    production:
      secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

Then he writes that there is no symbolic link to the **nginx.conf** file:
00:03 deploy:check:linked_files
          ERROR linked file /home/demo/myproject/shared/config/nginx.conf does not exist on 188.226.140.17

Regarding the **nginx.conf** file on
DigitalOcean's Tutorials , it says that you need to create a link in a slightly different place, not in the one indicated in my error, but nothing is said about **secrets.yml** at all .
My path is:
/home/demo/myproject/shared/config/nginx.conf
The path is as written in the tutorial :
sudo ln -nfs "/home/deploy/apps/appname/current/config/nginx.conf" "/etc/ nginx/sites-enabled/appname" I
substitute the name of my user in the command instead of **deploy** and the name of my application instead of **appname**. It turns out:
sudo ln -nfs "/home/demo/apps/myproject/current/config/nginx.conf" "/etc/nginx/sites-enabled/myproject"
Still writes an error:
00:03 deploy:check:linked_files
          ERROR linked file /home/demo/myproject/shared/config/nginx.conf does not exist on 188.226.140.17

Then I create not a link, but a file **nginx.conf**
touch /home/demo/mypoject/shared/config/nginx.conf
And fill it with the following content:
spoiler
upstream puma {
      server unix:///home/demo/apps/myproject/shared/tmp/sockets/myproject-puma.sock;
    }
    
    server {
      listen 80 default_server deferred;
      # server_name example.com;
    
      root /home/demo/apps/myproject/current/public;
      access_log /home/demo/apps/myproject/current/log/nginx.access.log;
      error_log /home/demo/apps/myproject/current/log/nginx.error.log info;
    
      location ^~ /assets/ {
        gzip_static on;
        expires max;
        add_header Cache-Control public;
      }
    
      try_files $uri/index.html $uri @puma;
      location @puma {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
    
        proxy_pass http://puma;
      }
    
      error_page 500 502 503 504 /500.html;
      client_max_body_size 10M;
      keepalive_timeout 10;
    }

***And this is where the fun begins!*** When trying to pull gems using Gemfile, the deployment hangs. At first I thought that this was how it should be, but after a long wait I realized that something was wrong here.
00:21 bundler:install
          01 ~/.rvm/bin/rvm default do bundle install --gemfile /home/demo/myproject/releases/20170525093300/Gemfile --path /home/demo/myproject/shared/bundle --without development test --deployment --quiet

I then tried to run the command on the server directly instead of via Capistrano from the client machine.
~/.rvm/bin/rvm default do bundle install --gemfile /home/demo/myproject/releases/20170525093300/Gemfile --path /home/demo/myproject/shared/bundle --without development test --deployment -- quiet
It seems to have gone further, but again began to give errors:
00:31 deploy:assets:precompile
          01 ~/.rvm/bin/rvm default do bundle exec rake assets:precompile
          01 rake aborted!
          01 ActiveRecord::AdapterNotSpecified: 'production' database is not configured. Available: []
          01 /home/demo/myproject/shared/bundle/ruby/2.3.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/connection_specification.rb:248:in `resolve_symbol_connection'
          01 /home/demo/myproject/shared/bundle/ruby/2.3.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/connection_specification.rb:211:in `resolve_connection'

I run this command on the server:
[email protected]:~$ ~/.rvm/bin/rvm default do bundle exec rake assets:precompile
Could not locate Gemfile or .bundle/ directory
But I have a Gemfile in both the Github repository and mine project! I
started to google the error and came across two or three similar questions, did as they advised, but still the deployment does not work. All the same error. Help me please. I'm new in this business.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artur Bordenyuk, 2017-05-25
@akimdi

The proposed article has a method that loads the config to the database on the server from the local machine

I run this command on the server:
[email protected]:~$ ~/.rvm/bin/rvm default do bundle exec rake assets:precompile
Could not locate Gemfile or .bundle/ directory
But I have a Gemfile in both the Github repository and mine project!

But the command is executed not from the project root, but from the user's home directory ([email protected]:~$)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question