原文请见我另外一个博客:http://caok1231.com/blog/2013/03/20/deploy-rails-app-with-mina/
capistrano是使用的最多的部署工具,最近社区中不少人开始推荐mina,试着用了下部署的速度的确快了很多。虽然mina最近两个月都没有更新,不过仍然希望这个项目能得到很好的发展。
下面简单总结下使用mina简单部署rails应用的过程。
1.安装mina
Gemfile中
group :development do
gem 'mina', :git => 'git://github.com/nadarei/mina.git'
end
使用mina 0.2.1的时候可能会出现Mina hangs after entering SSH password, 而0.2.0的版本没有这个问题,但为了使用最新的版本可以直接从原项目中取(这样的话在执行mina命令时要加上bundle exec).
2.初始化mina
bundle
bundle exec mina init
它将创建部署文件config/deploy.rb
3.创建你的服务器
$ ssh username@your.server.com
# Once in your server, create the deploy folder:
~@your.server.com$ mkdir /var/www/foobar.com
~@your.server.com$ chown -R username /var/www/foobar.com
这样可以避免部署时出现的sudo的错误
4.配置mina
config/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)
set :domain, 'foobar.com' # 设置你的ip地址或域名
set :deploy_to, '/var/www/foobar.com' # 设置部署的路径
set :repository, 'git://...' # git地址
#set :repository, File.expand_path('../../.git/', __FILE__) #直接取本地的git项目
set :branch, 'master' # 确定代码分支
# 设置需要共享的文件
set :shared_paths, ['config/database.yml', 'log', 'tmp']
# 可选设置
set :user, 'foobar' # SSH 用户名.
# set :port, '30000' # SSH 端口,默认22.
# 设置对于大多数的命令(mina deploy或mina rake)都需要预先加载的环境
task :environment do
# 如果使用的是rbenv,这么设置,但需确保.rbenv-version(rbenv local 1.9.3-p374)已经存在于你的项目中
invoke :'rbenv:load'
# 如果使用rvm,可以这样加载一个RVM version@gemset
# invoke :'rvm:use[ruby-1.9.3-p374@default]'
end
# mina setup 时会执行的操作
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"] # 设置配置目录权限
# 生成服务器的database.yml
queue! %[cd #{deploy_to}/shared && git archive --remote=#{repository} #{branch} config | tar -x config/database.yml]
end
# 进行mina deploy会进行的操作
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'
invoke :'rails:assets_precompile'
to :launch do
queue 'touch tmp/restart.txt'
end
end
end
5.服务器目录初始化
bundle exec mina setup
也可以这样操作,使提示更加详细些
bundle exec mina setup --verbose
6.进行项目部署
bundle exec mina deploy
查看其他命令
mina tasks
原文请见我另外一个博客:http://caok1231.com/blog/2013/03/20/deploy-rails-app-with-mina/
相关推荐
This concise teaches you how to use the power of Docker and Kubernetes to deploy your Rails applications easily and efficiently. Docker and Kubernetes are increasing in popularity every day, but what ...
Rails 经典开发参考书, Ruby on rails 系近年来在西方日渐盛行的一套网页开发工具,其高度集成化时开发时间大大缩短.
require : false 然后执行:$ bundle 或将其自己安装为:$ gem install mina-multistage 在您的config/deploy.rb需要mina/multistage : require 'mina/multistage'require 'mina/bundler'require 'mina/rails'...
前端开源库-ember-cli-deploy-appshellember cli部署appshell,基于applicationcache的shell,用于加载ember应用程序
This practical guide shows intermediate and advanced web and mobile app developers how to build highly scalable Java applications in the cloud with Google App Engine. The flagship of Google's Cloud ...
deploy_container_with_gpu.sh
使用Docker部署Rails应用程序 讲师: 本课程将介绍使用Docker容器部署标准数据库支持的Rails应用程序的过程。 由于该过程的功能集和易于部署,更有价值的部署的潜力,该过程正变得越来越受欢迎。 在本课程中,我们...
rails-app食谱 这是一本食谱,允许仅使用存储库即插即用地创建应用程序。 该食谱负责创建数据库,通过捆绑程序安装所需的gems以及创建nginx堆栈来服务您的站点。 要求 此食谱已在Ubuntu 12.04和Ubuntu 14.04上进行了...
Create_and_deploy_app
Ansible-rails-deploy.zip,Ansible脚本,用于设置完全加载的Ruby/Rails Web服务器Rails部署,ansible是一个简单而强大的自动化引擎。它用于帮助配置管理、应用程序部署和任务自动化。
Preparing to Deploy NSX with Britton Johnson (@vcixnv) and Aaron Bolthouse (@Bhouse563) [720p].mp4Preparing to Deploy NSX with Britton Johnson (@vcixnv) and Aaron Bolthouse (@Bhouse563) [720p].mp4
Rails 部署 Ansible 角色... rails_app_name : " {{ app_name }} " rails_app_user : " {{ app_user }} " rails_app_http_check_uri : " {{ app_healthcheck_uri }} " rails_app_host : 127.0.0.1 rails_app_platform :
自述文件 ...cd e5-deploy-with-docker-rails-api-single-node # edit docker-compose.yml to set the mysql & rails ports to be mapped on host docker-compose build bin/d_rails db:migrate bin/d
In addition, you’ll find half the book is stocked with new eye-opening solutions to such common problems as how to extend Rails, test and deploy your sites, or add a web service to your actions....
大神之作 puppet 自动部署 openstack,puppet 自动部署 openstack
Easy Deploy Rails 5 Application Server ( Nginx 1.10、Passenger 5、Ruby 2.3.1 ) ; 快速部署 Rails 5 伺服器
Docker Containers Build and Deploy with Kubernetes, Flannel, Cockpit, and Atomic 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书
自动部署导轨图最初是从GitLab的Auto-deploy Helm Chart( )派生的,但是由于需要工作人员,因此创建了此fork。 最初,sidekiq已实现。 延迟的工作应该是添加适当的命令的问题注意:Worker最初已添加到gitlabs自己...
By the end of the journey, you will learn how to package an app and deploy it to app markets. App Inventor 2 Essentials prepares you to amass a resource of skills, knowledge and experience to become ...
NULL 博文链接:https://kevinye.iteye.com/blog/390869