code-push-server 部署

1.下载node源并安装nodejs

curl -sL https://rpm.nodesource.com/setup_6.x | bash -
yum install -y nodejs

# 更换npm源,临时,永久,验证
1.临时更换npm源
npm --registry https://registry.npm.taobao.org install express
2.持久更换npm源
npm config set registry https://registry.npm.taobao.org

配置后可通过下面方式来验证是否成功
npm config get registry
npm info express

 2.下载安装code-push-server

cd /usr/local/
git clone https://github.com/lisong/code-push-server.git
cd code-push-server/
npm install

 3.初始化数据库(远程建立数据库,需要用到root,然后授权时用其他用户),需要有创建数据权限的用户

/usr/local/code-push-server/bin/db init --dbhost 10.160.5.187 --dbport 32959 --dbname codeplush --dbuser root --dbpassword 'PHxxxxxD'

 4.配置code-server数据库连接地址

cd /usr/local/code-push-server/config/
cp config.js config.js.bak
vim config.js
var config = {};
config.development = {
  // Config for database, only support mysql.
  db: {
    username: "code",
    password: "Codeservexxx",
    database: "codeplush",
    host: "10.160.5.187",
    port: 32959,
    dialect: "mysql",
    logging: false
  },

 

5.code-server建立的数据库授权

mysql -h 10.160.5.187 -u root -P 32959 -p
grant all on codeplush.* to code@'10.160.43.105' identified by 'Codeserve1xx';

 6.配置code-server,41,43,64,66行,

cd /usr/local/code-push-server/
mkdir data storage
vim /usr/local/code-push-server/config/config.js 39 local: { 40 // Binary files storage dir, Do not use tmpdir and it's public download dir. 41 storageDir: "/usr/local/code-push-server/storage", 42 // Binary files download host address which Code Push Server listen to. the files storage in storageDir. 43 downloadUrl: "http://112.124.xx.xx:3000/download", 44 // public static download spacename. 45 public: '/download' 46 }, ...... 51 }, 52 common: { ...... 63 // data dir for caclulate diff files. it's optimization. 64 dataDir: "/usr/local/code-push-server/data", 65 // storageType which is your binary package files store. options value is ("local" | "qiniu" | "s3") 66 storageType: "local",

 

7.启动服务

/usr/local/code-push-server/bin/www
nohup /usr/local/code-push-server/bin/www &

 8.修改密码(命令行模式我一直没修改成功********,用后面code-push-web界面修改)

curl -X PATCH -H "Authorization: Bearer 登录获取的token" -H "Accept: application/json" -H "Content-Type:application/json" -d '{"oldPassword":"123456","newPassword":"PHplush886"}' http://112.124.xx.xx:3000/users/password

 

9.安装 code-push-cli

code-push login 登陆
code-push logout 注销
code-push access-key ls 列出登陆的token
code-push access-key rm 删除某个 key值
code-push app add
code-push app

 操作

 

[root@tracker ~]# code-push app ls
┌─────────────────────┬─────────────────────┐
│ Name                │ Deployments         │
├─────────────────────┼─────────────────────┤
│ PinHui001RN-ios     │ Production, Staging │
├─────────────────────┼─────────────────────┤
│ PinHui001RN-android │ Production, Staging │
└─────────────────────┴─────────────────────┘

[root@tracker ~]# code-push deployment ls PinHui001RN-ios
┌────────────┬───────────────────────────────────────┬──────────────────────┐
│ Name       │ Update Metadata                       │ Install Metrics      │
├────────────┼───────────────────────────────────────┼──────────────────────┤
│ Production │ No updates released                   │ No installs recorded │
├────────────┼───────────────────────────────────────┼──────────────────────┤
│ Staging    │ Label: v7                             │ Active: 0% (0 of 0)  │
│            │ App Version: 1.5.5                    │ Total: 0             │
│            │ Mandatory: Yes                        │                      │
│            │ Release Time: 8 hours ago             │                      │
│            │ Released By: fei_li@silverbase.com.cn │                      │
│            │ Description: 20180508发布测试4            │                      │
└────────────┴───────────────────────────────────────┴──────────────────────┘
[root@tracker ~]# code-push deployment history  PinHui001RN-ios Staging
┌───────┬──────────────┬─────────────┬───────────┬───────────────┬─────────────────────┐
│ Label │ Release Time │ App Version │ Mandatory │ Description   │ Install Metrics     │
├───────┼──────────────┼─────────────┼───────────┼───────────────┼─────────────────────┤
│ v7    │ 8 hours ago  │ 1.5.5       │ Yes       │ 20180508发布测试4 │ Active: 0% (0 of 0) │
│       │              │             │           │               │ Total: 0            │
├───────┼──────────────┼─────────────┼───────────┼───────────────┼─────────────────────┤
│ v6    │ 9 hours ago  │ 1.5.5       │ Yes       │ 20180508发布测试3 │ Active: 0% (0 of 0) │
│       │              │             │           │               │ Total: 0            │
├───────┼──────────────┼─────────────┼───────────┼───────────────┼─────────────────────┤
│ v5    │ 9 hours ago  │ 1.5.5       │ Yes       │ 20180508发布测试1 │ Active: 0% (0 of 0) │
│       │              │             │           │               │ Total: 0            │
├───────┼──────────────┼─────────────┼───────────┼───────────────┼─────────────────────┤
│ v4    │ 9 hours ago  │ 1.5.5       │ Yes       │ 20180508发布测试1 │ Active: 0% (0 of 0) │
│       │              │             │           │               │ Total: 0            │
├───────┼──────────────┼─────────────┼───────────┼───────────────┼─────────────────────┤
│ v3    │ 9 hours ago  │ 1.5.6       │ Yes       │ 20180508发布测试1 │ Active: 0% (0 of 0) │
│       │              │             │           │               │ Total: 0            │
├───────┼──────────────┼─────────────┼───────────┼───────────────┼─────────────────────┤
│ v2    │ 9 hours ago  │ 1.5.6       │ Yes       │ 20180508发布测试  │ Active: 0% (0 of 0) │
│       │              │             │           │               │ Total: 0            │
├───────┼──────────────┼─────────────┼───────────┼───────────────┼─────────────────────┤
│ v1    │ Mar 7        │ 1.5.5       │ Yes       │ 20180307Test  │ Active: 0% (0 of 0) │
│       │              │             │           │               │ Total: 0            │
└───────┴──────────────┴─────────────┴───────────┴───────────────┴─────────────────────┘

 

10.安装 code-push-web

cd /usr/local/
git clone https://github.com/lisong/code-push-web.git
cd /usr/local/code-push-web/
npm install
vim /usr/local/code-push-web/src/config.js
# 修改 common 中的 URL 和 devURL
export const common = {
  api: {
    URL: `http://112.124.xx.xx:3000`, //production code-push-server address
    devURL: `http://112.124.xx.xx:3000` //development code-push-server address
  }
};

 11.配置code-web

cd /usr/local/code-push-web/
npm run build -- --release
cd ./build
npm install
node ./server.js
nohup node /usr/local/code-push-web/build/server.js &

 12.修改admin的密码,登陆http://112.124.xx.xx:3001/

 

 13.配置邮箱验证码收取,默认情况是收不到验证码,需要配置code-push-server里面的config.js

14.配置config.js文件

 

 

文档:

https://segmentfault.com/a/1190000008159508#articleHeader7

https://github.com/lisong/code-push-server

https://www.jianshu.com/p/88532d265202

 

posted @ 2018-01-30 16:22  sunmmi  阅读(706)  评论(0)    收藏  举报