码迷,mamicode.com
首页 > 其他好文 > 详细

老项目换unicorn的大致步骤

时间:2016-02-05 19:02:26      阅读:181      评论:0      收藏:0      [点我收藏+]

标签:

老项目换unicorn的大致步骤:

(1)修改config/application.rb
删除
 29     # assign log4r‘s logger as rails‘ logger.
 30     log4r_config= YAML.load_file(File.join(File.dirname(__FILE__),"log4r.yml"))
 31     YamlConfigurator.decode_yaml( log4r_config[‘log4r_config‘] )
 32     config.logger = Log4r::Logger[Rails.env]
新增memcached的配置
 29     config.cache_store = :dalli_store, *Settings.memcached.servers,
 30       { :namespace => Settings.memcached.namespace, :compress => true }

(2)新建config/deploy/文件夹,
    新增production.rb
      staging.rb

(3) 新增config/environments/
     development.rb
     production.rb
     staging.rb
     test.rb

(4) 修改Gemfile,删除thin,新增unicorn
 37 gem ‘dalli‘
 38 gem ‘unicorn‘
 39
 40 group :test, :development do
 41   gem "rspec-rails", ">= 2.5.0"
 42   gem ‘factory_girl‘, ‘2.6.4‘
 43   gem ‘factory_girl_rails‘, ‘1.7.0‘
 44   gem ‘faker‘, ‘1.1.2‘
 45   gem ‘forgery‘, ‘0.5.0‘
 46   gem ‘magic_encoding‘, ‘0.0.2‘
 47   gem ‘email_spec‘, ‘1.4.0‘
 48
 49   gem ‘net-ssh‘, ‘~> 2.0‘
 50   gem ‘capistrano‘, ‘~> 2.15.7‘
 51   gem ‘capistrano-rbenv‘, ‘1.0.5‘
 52   gem ‘rb-readline‘,‘0.4.2‘
 53 end

(5)修改配置config/settings.yml的配置
181 memcached:
182   namespace: xxx-xxxxx-cms-staging
183   servers:
184     - 127.0.0.1:11215

(6)配置config/deploy.rb文件

(7)bundle exec cap deploy:setup
bundle exec cap deploy:cold

部署可能出现的问题
(1)Could not parse object(由于写错了config/deploy.rb 里的set :repository导致的)


(2)不能自动识别config/application.rb的配置uninitialized constant Cms::Application::Settings
 修改Gemfile, gem "rails_config", ‘0.3.4‘


(3)/home/wz/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems /activesupport-3.0.8/lib/active_support/cache.rb:65:in `rescue in lookup_store‘: Could not find cache store adapter for dalli_store (cannot load such file -- active_support/cache/dalli_store) (RuntimeError)
需要加

gem ‘dalli‘

最后一步,把项目文件夹目录下的nginx配置做一个软链接到
$ nginx -t
nginx: the configuration file /opt/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /opt/nginx/conf/nginx.conf test is successful

$ ln -s /opt/app/ruby/tudou-tv-cms-unicorn/current/config/nginx.staging.conf /opt/nginx/conf/tudou_tv_cms.conf
12:33 [root@a02]$ nginx -t
nginx: the configuration file /opt/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /opt/nginx/conf/nginx.conf test is successful
tty:[0] jobs:[0] cwd:[~]
12:33 [root@a02]$ nginx -s reload
tty:[0] jobs:[0] cwd:[~]
12:33 [root@a02]$ netstat -tlnp | grep 52
tcp 0 0 0.0.0.0:5200 0.0.0.0:* LISTEN 20263/nginx
tcp 0 0 10.100.14.83:5308 0.0.0.0:* LISTEN 1526/cfservd
tcp 0 0 0.0.0.0:5218 0.0.0.0:* LISTEN 1391/thin server (0
12:33 [root@a02.test.stat.3g.vm.m6.youku]$ vim /opt/nginx/conf/nginx.conf
这里把新的链接include进来
include tudou_tv_cms.conf;
tty:[0] jobs:[0] cwd:[~]
12:34 [root@a02]$ nginx -t
nginx: the configuration file /opt/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /opt/nginx/conf/nginx.conf test is successful
tty:[0] jobs:[0] cwd:[~]
12:34 [root@a02]$ nginx -s reload
tty:[0] jobs:[0] cwd:[~]
12:34 [root@a02]$ netstat -tlnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:6500 0.0.0.0:* LISTEN 2347/thin server (0
tcp 0 0 0.0.0.0:6565 0.0.0.0:* LISTEN 20307/nginx
tcp 0 0 0.0.0.0:5030 0.0.0.0:* LISTEN 20307/nginx
tcp 0 0 0.0.0.0:22022 0.0.0.0:* LISTEN 26901/sshd
tcp 0 0 127.0.0.1:199 0.0.0.0:* LISTEN 26927/snmpd
tcp 0 0 127.0.0.1:6600 0.0.0.0:* LISTEN 11834/uwsgi

老项目换unicorn的大致步骤

标签:

原文地址:http://www.cnblogs.com/iwangzheng/p/5183242.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!