使用Mina部署和启动rails应用程序失败

时间:2014-08-12 16:04:51

标签: ruby-on-rails deployment thin mina

我使用Mina从我的git存储库部署到半生产服务器。我说半制作,因为它是我学士论文的一部分,我需要在真实的服务器上进行性能分析等。

我使用的gem需要为应用程序使用基于事件机器的Web服务器,我想使用rails提供的内部瘦服务器。

这就是我的deploy.rb目前的样子:

require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
# require 'mina/rbenv'  # for rbenv support. (http://rbenv.org)
require 'mina/rvm'    # for rvm support. (http://rvm.io)

# 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 :domain, 'server.myuni.edu'
set :user, 'captain'
set :port, '12343'
set :deploy_to, '/var/www/webpiraten'
set :repository, 'ssh://git@server.../webpiraten.git'
set :branch, 'production'

# They will be linked in the 'deploy:link_shared_paths' step.
set :shared_paths, ['log']

set :rvm_path, '/usr/local/rvm/scripts/rvm'

# This task is the environment that is loaded for most commands, such as
# `mina deploy` or `mina rake`.

task :environment do
  # If you're using rbenv, use this to load the rbenv environment.
  # Be sure to commit your .rbenv-version to your repository.
  # invoke :'rbenv:load'

  # For those using RVM, use this to load an RVM version@gemset.
  invoke :'rvm:use[ruby-2.0.0@default]'
end

# Put any custom mkdir's in here for when `mina setup` is ran.
# For Rails apps, we'll make some of the shared paths that are shared between
# all releases.
task :setup => :environment do
  queue! %[mkdir -p "#{deploy_to}/shared/log"]
  queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/log"]

  queue! %[mkdir -p "#{deploy_to}/shared/config"]
  queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/config"]

  queue! %[touch "#{deploy_to}/shared/config/database.yml"]
  queue  %[echo "-----> Be sure to edit 'shared/config/database.yml'."]
end

desc "Deploys the current version to the server."
task :deploy => :environment do
  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' # we don't use a database
    invoke :'rails:assets_precompile'

    to :launch do
      queue "pkill ruby" # ToDo
      queue "bundle exec thin start -e production"
    end
  end
end

如果我跑

mina deploy

它确实获取资源部署和预编译资产,但启动失败时显示:

-----> Updating the current symlink       
-----> Launching       
 !     ERROR: Deploy failed.  
-----> Cleaning up build       
       Deleting release
       Unlinking current
       OK

 !     Command failed.
       Failed with status 19

这似乎是服务器启动,但我不知道为什么。如果我跑

bundle exec thin start -e production -p 3000

手动,它确实有效。

有没有人知道如何在不遇到此问题的情况下正确启动服务器?

由于

1 个答案:

答案 0 :(得分:0)

问题实际上是pkill。删除/替换解决了这个问题。