0

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

我使用的 gem 需要为应用程序使用基于事件机的网络服务器,我想使用 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

手动,它确实有效。

有谁知道如何正确启动服务器而不会遇到此问题?

谢谢

4

1 回答 1

0

实际上,问题出在 pkill 上。删除/更换解决了问题。

于 2014-08-14T08:40:24.407 回答