ruby-on-rails - 使用 Mina 部署 Rails5 应用程序的部署问题。挂起更新符号链接(symbolic link)

标签 ruby-on-rails deployment ubuntu-16.04

部署 mina 后,它卡在“更新/home/x/app/current 符号链接(symbolic link)”上。没有错误。它只是坐在那里。

我已经尝试从服务器和“mina setup”中删除应用程序目录,但仍然遇到同样的问题。我最初部署没有问题,但似乎任何尝试部署后续版本都会导致这个问题。

我最初是按照本指南进行部署的:https://www.ralfebert.de/tutorials/rails-deployment/

require 'mina/rails'
require 'mina/git'
require 'mina/rvm'

# Basic settings:
#   domain       - The hostname to SSH to.
#   deploy_to    - Path to deploy into.
#   repository   - Git repo to clone from. (needed by mina/git)
#   branch       - Branch name to deploy. (needed by mina/git)

set :application_name, 'x'
set :domain, 'x'
set :user, fetch(:application_name)
set :deploy_to, "/home/#{fetch(:user)}/app"
set :repository, 'x'
set :branch, 'x'
set :rvm_use_path, '/etc/profile.d/rvm.sh'

# Optional settings:
#   set :user, 'foobar'          # Username in the server to SSH to.
#   set :port, '30000'           # SSH port number.
#   set :forward_agent, true     # SSH forward_agent.

# shared dirs and files will be symlinked into the app-folder by the 'deploy:link_shared_paths' step.
# set :shared_dirs, fetch(:shared_dirs, []).push('somedir')
set :shared_files, fetch(:shared_files, []).push('config/database.yml', 'config/secrets.yml')

# This task is the environment that is loaded for all remote run commands, such as
# `mina deploy` or `mina rake`.
task :environment do
  ruby_version = File.read('.ruby-version').strip
  raise "Couldn't determine Ruby version: Do you have a file .ruby-version in your project root?" if ruby_version.empty?

  invoke :'rvm:use', ruby_version
end

task :setup do

  in_path(fetch(:shared_path)) do

    command %[mkdir -p config]

    # Create database.yml for Postgres if it doesn't exist
    path_database_yml = "config/database.yml"
    database_yml = %[production:
  database: #{fetch(:user)}
  adapter: postgresql
  pool: 5
  timeout: 5000]
    command %[test -e #{path_database_yml} || echo "#{database_yml}" > #{path_database_yml}]

    # Create secrets.yml if it doesn't exist
    path_secrets_yml = "config/secrets.yml"
    secrets_yml = %[production:\n  secret_key_base:\n    #{`rake secret`.strip}]
    command %[test -e #{path_secrets_yml} || echo "#{secrets_yml}" > #{path_secrets_yml}]

    # Remove others-permission for config directory
    command %[chmod -R o-rwx config]
  end

end

desc "Deploys the current version to the server."
task :deploy do
  # uncomment this line to make sure you pushed your local branch to the remote origin
  # invoke :'git:ensure_pushed'
  deploy do
    # Put things that will set up an empty directory into a fully set-up
    # instance of your project.
    invoke :'git:clone'
    invoke :'deploy:link_shared_paths'
    invoke :'bundle:install'
    # invoke :'rails:db_migrate'
    invoke :'rails:assets_precompile'
    invoke :'deploy:cleanup'

    on :launch do
      command "sudo service #{fetch(:user)} restart"
    end
  end

  # you can use `run :local` to run tasks on local machine before of after the deploy scripts
  # run(:local){ say 'done' }
end

# For help in making your deploy script, see the Mina documentation:
#
#  - https://github.com/mina-deploy/mina/tree/master/docs

最佳答案

我用了同样好的教程,遇到了同样的问题。

您可以运行 mina deploy --verbose 来查看卡住的位置。 对我来说,这不是符号链接(symbolic link)更新,而是 sudo service rails-demo restart 命令。

我在服务器上使用了 sudo visudo 并将以下行放在那里:

rails-demo ALL=(ALL) NOPASSWD: /usr/sbin/service rails-demo restart

现在它就像一个魅力。

祝你好运!

关于ruby-on-rails - 使用 Mina 部署 Rails5 应用程序的部署问题。挂起更新符号链接(symbolic link),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47419596/

相关文章:

azure - Service Fabric 部署卡在 GetApplicationExistence 上

ubuntu-16.04 - 在 Windows X86-64 主机上运行的 qemu-system-aarch64 中启用 Virt Machine Graphics

无法捕获 C 中的击键 [Ubuntu 16.04LTS]

javascript - 将 ruby​​ 数组转换为 javascript 数组无法正常工作

ruby 中的 Mysql 连接查询有两个条件

ruby-on-rails - Rails - 呈现自定义 xml

java - ActiveResource 的基本假设端点是什么?

kubernetes - 如何修复 “Tried to associate with unreachable remote address [akka.tcp://actorsystem@address:port]”错误?

java - 部署使用 Netbeans 编译的 Java 应用程序 - 找不到第 3 方类

apache - 具有两个不同日志文件的两个站点 - SSL Apache2 Ubuntu