CodePush 是提供給 React Native 和 Cordova 開發者直接部署移動應用更新給用戶設備的雲服務。CodePush 作為一個中央倉庫,開發者可以推送更新 (JS, HTML, CSS and images),應用可以從客戶端 SDK 里面查詢更新。CodePush 可以讓應用有更多的可確定性,也可以讓你直接接觸用戶群。在修復一些小問題和添加新特性的時候,不需要經過二進制打包,可以直接推送代碼進行實時更新。
CodePush Server是CodePush程序服務器! 微軟的CodePush雲在中國很慢,我們可以用它來構建我們的。 我使用七牛來存儲文件,因為它簡單快捷! 或者你可以使用[local / s3 / oss / tencentcloud]存儲,只需修改config.js文件,它就是簡單的配置。
--------------
CodePush應用更新流程
------------------
1、安裝node.js和npm
https://www.cnblogs.com/wood-life/p/10577516.html
2、安裝MySQL(推薦5.7經典版本)
3、從npm上獲取code-push-server
$ npm install code-push-server@latest -g
[root@wood ~]# npm i -g pm2
/usr/local/lib/nodejs/node-v8.16.0-linux-x86/bin/pm2 -> /usr/local/lib/nodejs/node-v8.16.0-linux-x86/lib/node_modules/pm2/bin/pm2
/usr/local/lib/nodejs/node-v8.16.0-linux-x86/bin/pm2-dev -> /usr/local/lib/nodejs/node-v8.16.0-linux-x86/lib/node_modules/pm2/bin/pm2-dev
/usr/local/lib/nodejs/node-v8.16.0-linux-x86/bin/pm2-docker -> /usr/local/lib/nodejs/node-v8.16.0-linux-x86/lib/node_modules/pm2/bin/pm2-docker
/usr/local/lib/nodejs/node-v8.16.0-linux-x86/bin/pm2-runtime -> /usr/local/lib/nodejs/node-v8.16.0-linux-x86/lib/node_modules/pm2/bin/pm2-runtime
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.8 (node_modules/pm2/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.8: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"ia32"})
+ pm2@3.5.0
added 310 packages from 258 contributors in 22.057s
[root@wood ~]# npm install code-push-server@latest -g
npm WARN deprecated circular-json@0.5.9: CircularJSON is in maintenance only, flatted is its successor.
> typechecker@2.0.8 preinstall /usr/local/lib/nodejs/node-v8.16.0-linux-x86/lib/node_modules/code-push-server/node_modules/extract-opts/node_modules/typechecker
> node ./cyclic.js
> typechecker@2.0.8 preinstall /usr/local/lib/nodejs/node-v8.16.0-linux-x86/lib/node_modules/code-push-server/node_modules/extendr/node_modules/typechecker
> node ./cyclic.js
/usr/local/lib/nodejs/node-v8.16.0-linux-x86/bin/code-push-server -> /usr/local/lib/nodejs/node-v8.16.0-linux-x86/lib/node_modules/code-push-server/bin/www
/usr/local/lib/nodejs/node-v8.16.0-linux-x86/bin/code-push-server-db -> /usr/local/lib/nodejs/node-v8.16.0-linux-x86/lib/node_modules/code-push-server/bin/db
+ code-push-server@0.5.4
added 440 packages from 498 contributors in 25.962s
4、初始化數據庫
$ code-push-server-db init --dbhost "127.0.0.1" --dbport "3306" --dbuser "root" --dbpassword "12345678"
5、編輯code-push-server的config.js配置文件和process.json
config.js
local
.storageDir
改成自己本地目錄且保證當前用戶有讀寫權限(推薦使用root用戶)local
.downloadUrl
替換127.0.0.1
為本機ip,其實這里不用改,后面用Nginx反向代理127.0.0.1:3000 -> https://your-domain/code-push-servercommon
.dataDir
改成自己本地目錄且保證當前用戶有讀寫權限jwt
.tokenSecret
從https://www.grc.com/passwords.htm
網站中獲取隨機串替換INSERT_RANDOM_TOKEN_KEY
db
配置數據庫也就是第4步中的初始化信息:username
,password
,host
,port
script
指向你安裝的目錄,通過npm安裝code-push-server后控制台中會顯示此地址code-push-server/bin/www
CONFIG_FILE
指向config.js絕對路徑
6、