本文主要包含企业erp解决,企业无线网络解决方案,小企业借贷难如何解决,帮助企业解决困难,企业网络安全解决方案等服务器相关知识,网友希望可以进行参考
上周给大家介绍了capistrano,它可以帮助我们来解决代码自动部署与回滚的软件,但这个软件还是有点缺点,比如如果你同时有多个项目的时候,就得创建多个目录,然后每次进行代码更新的时候,进入到不同的目录中去,十分的麻烦,所以本文介绍的caphub就是为了解决这个问题。
目录
一、简介
二、安装
三、测试
四、capistrano或caphub在企业里真实环境软件自动化部署需求
一、简介
Caphub是一个适合企业应用的自动化部署与回滚软件,他的好处为:
Main idea of caphub is separate deployment and application code. So instead of capify your each project create one caphub repository and put all configurations/recipes there. Benefits: no deployment/application code mix. all deployment located in place. ability to deploy multiple projects deployment is not limited application deployment - deploy your system configurations too! (nginx/haproxy/etc configs) easy to share configurations/recipes among multiple deployment. uptodate synchronizing with remote repository (with capistrano-uptodate). generate layout with caphub or write it yourself from scratch with your own recipes
简单的话,如果你有多个项目需要自动化部署的话,多个项目配置文件可以集中放在一个地方,caphub更适合解决这样问题。具体情况看下面的测试。
二、安装
本文的测试环境为ubuntu server 12.04
gem install caphub caphub caphub_test root@server:~/capistrano# tree --dirsfirst caphub_test/ caphub_test/ |-- config | |-- deploy | `-- deploy.rb |-- recipes |-- Capfile |-- Gemfile `-- Gemfile.lock
初始化gemsinitialize gems)
cd caphub_test bundle install
安装完成后可以使用cap –vT查看任务信息
root@server:~/capistrano/caphub_test# cap -vT cap deploy # Deploys your project. cap deploy:check # Test deployment dependencies. cap deploy:cleanup # Clean up old releases. cap deploy:cold # Deploys and starts a `cold' application. cap deploy:create_symlink # Updates the symlink to the most recently deployed version. cap deploy:finalize_update # [internal] Touches up the released code. cap deploy:migrate # Run the migrate rake task. cap deploy:migrations # Deploy and run pending migrations. cap deploy:pending # Displays the commits since your last deploy. cap deploy:pending:diff # Displays the `diff' since your last deploy. cap deploy:restart # Blank task exists as a hook into which to install your own environment specific behaviour. cap deploy:rollback # Rolls back to a previous version and restarts. cap deploy:rollback:cleanup # [internal] Removes the most recently deployed release. cap deploy:rollback:code # Rolls back to the previously deployed version. cap deploy:rollback:revision # [internal] Points the current symlink at the previous revision. cap deploy:setup # Prepares one or more servers for deployment. cap deploy:start # Blank task exists as a hook into which to install your own environment specific behaviour. cap deploy:stop # Blank task exists as a hook into which to install your own environment specific behaviour. cap deploy:symlink # Deprecated API. cap deploy:update # Copies your project and updates the symlink. cap deploy:update_code # Copies your project to the remote servers. cap deploy:upload # Copy files to the currently deployed version. cap deploy:web:disable # Present a maintenance page to visitors. cap deploy:web:enable # Makes the application web-accessible again. cap invoke # Invoke a single command on the remote servers. cap multiconfig:ensure # [internal] Ensure that a configuration has been selected cap patch # Create, deliver and apply patch cap patch:apply # Apply patch cap patch:create # Create patch cap patch:deliver # Deliver patch cap patch:revert # Revert patch cap shell # Begin an interactive Capistrano session. cap uptodate # Automatically synchronize current repository cap uptodate:git # Extended help may be available for these tasks. Type `cap -e taskname' to view it.
由于当前没有创建都是空的
三、测试结合svn的部署
1、内容
先进入到deploy目录
root@server:~/capistrano/caphub_test# cd config/deploy root@server:~/capistrano/caphub_test/config/deploy# ll total 12 drwxr-xr-x 2 root root 4096 Jul 30 12:22 ./ drwxr-xr-x 3 root root 4096 Jul 30 10:18 ../ -rw-r--r-- 1 root root 0 Jul 30 10:18 .gitkeep
然后展示一下我的svn部署的内容
root@server:~/capistrano/caphub_test/config/deploy# cat svn.rb set :application, "test_svn" set :scm, :subversion set :repository, "https://192.168.1.56/svn/ops_manage" set :scm_username, "denglei" set :scm_password, "123456" set :deploy_to, "/tmp/result_svn/ops_manage" set :normalize_asset_timestamps, false # set :scm, :git # You can set :scm explicitly or Capistrano will make an intelligent guess based on known version control directory names role :web, "192.168.56.101" # Your HTTP server, Apache/etc role :app, "192.168.56.101" # This may ber role :db, "192.168.56.101", :primary => true # This is where Rails migrations will run root@server:~/capistrano/caphub_test/config/deploy# ll /tmp/red redis/ redis.pl redmine-2.3.1/ redmine-2.3.1.tar.gz redmine1.sql root@server:~/capistrano/caphub_test/config/deploy# ll /tmp/red redis/ redis.pl redmine-2.3.1/ redmine-2.3.1.tar.gz redmine1.sql
在看看我的tmp目录下是否有result_svn目录
root@server:~/capistrano/caphub_test/config/deploy# ll /tmp/result_svn ls: cannot access /tmp/result_svn: No such file or directory
可以看到没有
然后在看看当前的任务信息
root@server:~/capistrano/caphub_test/config/deploy# cap -vT cap deploy # Deploys your project. cap deploy:check # Test deployment dependencies. cap deploy:cleanup # Clean up old releases. cap deploy:cold # Deploys and starts a `cold' application. cap deploy:create_symlink # Updates the symlink to the most recently deployed version. cap deploy:finalize_update # [internal] Touches up the released code. cap deploy:migrate # Run the migrate rake task. cap deploy:migrations # Deploy and run pending migrations. cap deploy:pending # Displays the commits since your last deploy. cap deploy:pending:diff # Displays the `diff' since your last deploy. cap deploy:restart # Blank task exists as a hook into which to install your own environment specific behaviour. cap deploy:rollback # Rolls back to a previous version and restarts. cap deploy:rollback:cleanup # [internal] Removes the most recently deployed release. cap deploy:rollback:code # Rolls back to the previously deployed version. cap deploy:rollback:revision # [internal] Points the current symlink at the previous revision. cap deploy:setup # Prepares one or more servers for deployment. cap deploy:start # Blank task exists as a hook into which to install your own environment specific behaviour. cap deploy:stop # Blank task exists as a hook into which to install your own environment specific behaviour. cap deploy:symlink # Deprecated API. cap deploy:update # Copies your project and updates the symlink. cap deploy:update_code # Copies your project to the remote servers. cap deploy:upload # Copy files to the currently

