I use Mina to deploy from my git repository to a semi production server. I say semi production because it is part of my bachelor thesis and I need to run it on a real server for performance analysis and such.
A gem I use requires to use an event-machine based webserver for the application and I wanted to use the internal thin server provided by rails.
This is what my deploy.rb currently looks like:
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
If I run
mina deploy
It does fetch the sources deploy and precompile the assets, but the launching fails with:
-----> Updating the current symlink
-----> Launching
! ERROR: Deploy failed.
-----> Cleaning up build
Deleting release
Unlinking current
OK
! Command failed.
Failed with status 19
It seems to be the server startup, but I don't know why. If I run
bundle exec thin start -e production -p 3000
manually, it does work.
Does anyone know how to properly start the server without running into this issue?
Thanks
It was actually pkill that was the problem. Removing/replacing that solved the issue.