Browse Source

first commit

Willin Wang 7 years ago
commit
deadc2e602

+ 5 - 0
.gitignore

@@ -0,0 +1,5 @@
+_book/
+node_modules/
+
+.DS_Store
+*.log

+ 0 - 0
.nojekyll


+ 15 - 0
INTRO.md

@@ -0,0 +1,15 @@
+# 可替代团队领袖培养计划
+
+本书主要包括如下几个方面:
+
+一、系统运维
+
+包括自动化测试、持续集成(CI)等。
+
+二、系统化设计
+
+包括产品设计和架构设计。
+
+三、编程算法
+
+一些技术小细节。

+ 23 - 0
README.md

@@ -0,0 +1,23 @@
+# Replacer
+
+## 《可替代的团队领袖培养计划》
+
+
+### 安装
+
+```bash
+npm i -g gitbook-cli
+gitbook install
+```
+
+### 本地运行
+
+```bash
+gitbook serve
+```
+
+### 打包生成
+
+```bash
+gitbook build
+```

+ 4 - 0
SUMMARY.md

@@ -0,0 +1,4 @@
+# Summary
+
+- 运维
+  - [CI工作流](operation/workflow.md)

+ 19 - 0
_static/main.js

@@ -0,0 +1,19 @@
+(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
+
+ga('create', 'UA-33096931-4', 'auto');
+ga('send', 'pageview');
+window.onload = function() {
+    setTimeout(function() {
+      var ad = document.querySelector("ins.adsbygoogle");
+      if (ad && ad.innerHTML.replace(/\s/g, "").length == 0) {
+        if (typeof ga !== 'undefined') {
+            ga('send', 'event', 'Adblock', 'Yes');
+        } else if (typeof _gaq !== 'undefined') {
+            _gaq.push(['_trackEvent', 'Adblock', 'Yes']);
+        }
+      }
+    }, 2000); 
+  };

BIN
_static/operation/workflow1.png


BIN
_static/operation/workflow2.png


BIN
_static/operation/workflow3-1.png


BIN
_static/operation/workflow3-2.png


BIN
_static/operation/workflow3-3.png


BIN
_static/operation/workflow4-1.png


BIN
_static/operation/workflow4-2.png


+ 60 - 0
book.json

@@ -0,0 +1,60 @@
+
+{
+    "title": "可替代的团队领袖培养计划",
+    "description": "Author: Willin Wang",
+    "language": "zh-cn",
+    "gitbook": "=2.5.2",
+    "structure": {
+        "readme": "INTRO.md"
+    },
+    "plugins": [
+      "addcssjs",
+      "atoc",
+      "fancybox",
+      "donate",
+      "github",
+      "-disqus",
+      "edit-link",
+      "adsense",
+      "-maxiang"
+    ],
+    "pluginsConfig": {
+        "donate": {
+          "wechat": "http://go.sh.gg/images/wx.png",
+          "alipay": "http://go.sh.gg/images/alipay.png",
+          "title": "如果您觉得受益,请打赏支持!",
+          "button": "赏"
+        },
+        "fontsettings": {
+            "family": "sans",
+            "size": 2
+        },
+        "fancybox":{
+
+        },
+        "github": {
+            "url": "https://coding.net/u/willin/p/leader.js.cool/git"
+        },
+        "edit-link": {
+            "base": "https://coding.net/u/willin/p/leader.js.cool/git/edit/master/",
+            "label": "编辑此页"
+        },
+        "disqus": {
+          "shortName": "money-js-cool"
+        },
+        "atoc": {
+          "addClass": true,
+          "className": "atoc"
+        },
+        "addcssjs": {
+          "js": ["_static/main.js"]
+        },
+        "adsense": {
+          "client": "ca-pub-5059418763237956",
+          "slot": "2139110924",
+          "format": "auto",
+          "element": ".page-inner section"
+        },
+        "introduction-text": "封面"
+    }
+}

+ 102 - 0
operation/workflow.md

@@ -0,0 +1,102 @@
+# 持续交付工作流
+
+阿里云持续交付平台: <https://crp.aliyun.com/>
+
+## 1.触发器任务
+
+![Image](/_static/operation/workflow1.png)
+
+点击红色箭头所指圆圈位置设置触发器任务。
+
+一般情况下,需要部署到产品环境是侦听`Master`分支,集成测试可以为其他开发分支。
+
+本文示例以一套完整的自动化测试部署流程为例,选择了`Master`分支。
+
+## 2.代码检出
+
+![Image](/_static/operation/workflow2.png)
+
+这里的信息都是自动填入的,无需做更改。
+
+## 3.集成测试
+
+如果是简单的测试脚本,如单元测试,不需要数据库的。可以直接使用阿里云的编译测试功能,如下图所示:
+
+![Image](/_static/operation/workflow3-1.png)
+
+如果有专门的测试服务,可以用如下图所示方式进行测试:
+
+![Image](/_static/operation/workflow3-2.png)
+
+提示:CRP提供的测试环境是Ubuntu,未安装数据库,但据说可以自己安装,目前还没有尝试过。
+
+### 注意点
+
+#### 自动完成
+
+左侧活动信息中,【自动完成】选项,如果勾选,则测试通过就会自动进入下一步(如部署产品环境),否则会停在这里,需要手动触发,如下图所示:
+
+![Image](/_static/operation/workflow3-3.png)
+
+#### 表单项
+
+##### 目标机器
+
+填入测试服务器ip。
+
+##### 部署路径
+
+可以是用户目录,如 `/home/user/`
+
+或是项目目录,如 `/home/user/project`
+
+无太大影响,因为【部署命令】中可以使用 `cd` 命令。
+
+一般这里我填入的是用户目录。
+
+##### 部署命令
+
+流程:
+
+0. 根据需要,启动、重启数据库/缓存服务(一般可以不用放在自动测试流程里)
+1. 进入项目目录
+2. 更新代码,新建当前版本分支,以备回滚操作
+3. 更新依赖项
+4. 启动测试脚本
+
+Shell命令
+
+```bash
+cd /home/xxx-user/xxx-project/
+git checkout .
+git fetch
+git checkout $CODE_VERSION
+npm -d install
+npm update
+npm test
+# 产品环境加入:
+# pm2 reload xxx-server-name
+```
+
+##### 登录用户
+
+SSH 登入服务的用户名称
+
+提示: 系统需要您的目标机器添加部署公钥方可执行部署任务。请将公钥拷贝到服务器部署用户目录的$HOME/.ssh/authorized_keys文件中。
+
+## 4.自动部署
+
+### 新建流程
+
+模板默认流程只有两个,需要新建的时候根据下图:
+
+![Image](/_static/operation/workflow4-1.png)
+
+箭头所指小圆圈部分单击拖拽新建一个工作流,并将结束定向到新的工作流上。
+
+![Image](/_static/operation/workflow4-2.png)
+
+### 注意点
+
+1. 【自动触发】、【自动完成】勾选上,如果需要,还可以打开【异常通知】
+2. 【目标机器】如有多台负载均衡横向扩展的相同环境机器以逗号分隔

+ 29 - 0
package.json

@@ -0,0 +1,29 @@
+{
+  "name": "w2mn",
+  "version": "1.0.0",
+  "description": "百万富翁之路",
+  "main": "index.js",
+  "scripts": {
+    "start": "sh deploy.sh",
+    "test": "node_modules/.bin/gitbook serve"
+  },
+  "repository": {
+    "type": "git",
+    "url": "git+ssh://git@git.coding.net/willin/w2mn.git"
+  },
+  "keywords": [
+    "money",
+    "cool",
+    "w2mn",
+    "millionaire"
+  ],
+  "author": "Willin Wang",
+  "license": "MIT",
+  "bugs": {
+    "url": "https://coding.net/u/willin/p/w2mn/topic"
+  },
+  "homepage": "https://coding.net/u/willin/p/w2mn/git",
+  "dependencies": {
+    "gitbook-cli": "^2.2.0"
+  }
+}