系统拆分全纪实

iwangzheng.com

以上是在大师和PP的指导 下完成的,非常感谢

1. 未雨绸缪:  先到 http://gforge.1verge.net/gf/ 申请一个新的项目m_cms_iphone。非常快就收到开通邮件了, 很开心,于是又申请了一个别的项目尝试下,刚申请完忙点别的事,回来发现又收到开通邮件了,简直是秒杀啊.

(这里有一点需要注意的是 选择代码管理方式为git,而不是svn ,这样等半个小时以后,代码下载地址就有效啦)
== 核心: 我们不是先新建 光秃秃的项目,再添加代码。
要做减法: 先COPY一个新项目,再砍掉没用的东东。
优点:
1. 马上就能跑起来。
2. 多余的东西,可以暂时隐藏掉。
3. 省时省力。

缺点:  会有一些冗余的代码。
===========

2. COPY代码到一个新的文件夹。

3. $ cp m-cms    m_cms_iphone -r

4. 删掉: views,  controllers. helpers, spec....

$ rm .git -rf
$ rm -rf .idea
$ rm .gitignore
$ rm .rspec
5. 但是: 记得保留: models!  (因为 )
6. 精简 routes.rb
7. 精简 左侧菜单。
8. 单元测试就可以跑起来了。
9. 修改 部署脚本。 (config/deploy.rb )
10. 把它push 到第一步申请的项目中去。

这里需要注意啦,过程是这样的,先找到gforge上面找到代码下载地址,把整个文件下载下来,随便放个临时的文件夹里就ok,之后把这个文件夹下面的 .git 拷贝到g刚才新建的项目文件夹里.

$git clone ssh://姓名@gforge.1verge.net:端口号/gitroot/m_cms_iphone

$cp .git/  ../m_cms_iphone/ -r

$ git add .

$git commit -m 'initial'

$git pull

$git push --set-upstream origin master

11. 可以在wiki上建立对应的页面。

12. 修改服务器上nginx配置

server {
listen 5000;

location /iphone {
proxy_pass http://10.103.13.103:3660/iphone;
}
location /interface/iphone {
proxy_pass http://10.103.13.103:3660/interface/iphone;
}

}

server {
listen 80;

location /iphone {
proxy_pass http://10.103.13.103:3660/iphone;
}
location /interface/iphone{
proxy_pass http://10.103.13.103:3660/interface/iphone;
}

}

server {
listen 3660;

allow 10.0.0.0/8;
deny all;

charset utf-8;
location / {
proxy_pass http://iphone_servers;
proxy_redirect default;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_next_upstream http_502 http_504 error timeout invalid_header;
}
}

upstream iphone_servers{
server 127.0.0.1:6300;
server 127.0.0.1:6301;
}

最终访问的端口是6300和6301

发布过程中遇到了一点点小问题,报错内容是无法删除current文件夹,原因是current是一个软链接,我在服务器上手动建了个current,所以报错啦,在服务器上执行ll的时候可以看到,current  是 lrwxrwxrwx,releases是drwxrwxrwx,首字母一个是l,表示link,一个是  d ,表示directory

原文地址:https://www.cnblogs.com/iwangzheng/p/3679887.html