不要使用Capistrano

时间:2017-05-25 14:11:03

标签: ruby-on-rails ruby capistrano digital-ocean

我正按照instruction进行操作,但仍然无效。
服务器写道,我没有文件 database.yml

的符号链接
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需要手动创建文件 database.yml 我创建了database.yml

touch /home/demo/myproject/shared/config/database.yml


production:
  adapter: postgresql
  encoding: utf8
  database: myproject_db
  username: postgres
  password: 1234567890postgres
  host: localhost
  pool: 5
  min_messages: WARNING

此外,他写道,文件 secrets.yml 没有符号链接:

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

在服务器上创建 secrets.yml

touch /home/demo/myproject/shared/config/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"] %>

此外,他写道,没有符号链接到文件** nginx.conf **:

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

关于 nginx.conf 文件 Tutorials DigitalOcean 有人写道,有必要在其他地方稍微创建符号链接,而不是在错误中指定给我的符号链接,以及 secrets.yml 它被告知了。 我服务器中的路径:

/home/demo/myproject/shared/config/nginx.conf

路径写在tutorial

sudo ln -nfs "/home/deploy/apps/appname/current/config/nginx.conf" "/etc/nginx/sites-enabled/appname"

我将用户名替换为部署,而不是 appname 我的应用程序名称。事实证明:

sudo ln -nfs "/home/demo/apps/myproject/current/config/nginx.conf" "/etc/nginx/sites-enabled/myproject"

仍在写错误:

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

然后我创建的不是符号链接,而是文件** nginx.conf **

touch /home/demo/mypoject/shared/config/nginx.conf


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;
}

这里开始最有趣了! 当我尝试用Gemfile拉宝石时 - 部署挂起。我一开始以为这应该是这样的,但经过漫长的等待后,我才意识到有些事情是不对的。

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

然后我尝试直接在服务器上执行此命令。

~/.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

似乎更进一步,但又开始出错:

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'

我在服务器上执行此命令:

demo@test8CPU:~$ ~/.rvm/bin/rvm default do bundle exec rake assets:precompile
Could not locate Gemfile or .bundle/ directory

但我在Github和我的项目中的存储库中有Gemfile! 我正在使用Google搜索并找到相关问题 first second third 但他们没有帮助。还是一样的错误。

请帮帮我。我是新手。

1 个答案:

答案 0 :(得分:0)

demo@test8CPU:~$ ~/.rvm/bin/rvm default do bundle exec rake assets:precompile
Could not locate Gemfile or .bundle/ directory

这很简单。你不在app文件夹中。以前的命令有效,因为它们有--gemfile--path等参数。 bundle exec没有这样的论点。

解决方案是

cd /home/demo/myproject/current

~/.rvm/bin/rvm default do bundle exec rake assets:precompile