codepush熱更新
codepush2之配置自己的服務器
codepush3之Android原生引用集成codepush
通過ssh方式遠程連接服務器
ssh 用戶名@ip
例如:
ssh [email protected]
用戶名:root
密碼:123456
服務器配置
1:
通過nvm安裝node
安裝nvm
參考:https://github.com/creationix/nvm#install-script
nvm ls-remote (查看node版本)
nvm install v8.9.4 (安裝某個版本node)
2:
cd /
在/ 目錄下 新建app文件夾(mkdir app)
cd app
新建 db目錄(mkdir db)
cd db
新建 文件夾data ,storage用於存儲更新上傳的文件
3:
下載code-push-server
wget https://github.com/lisong/code-push-server/archive/master.zip
4:
解壓unzip master.zip
如果沒有unzip 安裝yum install -y unzip
yum命令:http://www.linuxidc.com/Linux/2016-05/131702.htm
5:
安裝數據庫
cat /etc/centos-release 查看linux版本
因爲我是cenOS7
yum -y install mariadb mariadb-server
6:
啓動,配置數據庫賬號密碼
centos7啓動和設置mysql/mariadb
7:配置config.js
db: {
username: "root",
password: "123456",
database: "codepush",
host: "127.0.0.1",
port: 3306,
dialect: "mysql",
logging: false
},
local: {
// Binary files storage dir, Do not use tmpdir and it's public download dir.
storageDir: "/app/db/storage",
// Binary files download host address which Code Push Server listen to. the files storage in storageDir.
downloadUrl: "http://172.28.32.244:3000/download",
// public static download spacename.
public: '/download'
},
jwt: {
//網站獲取
// Recommended: 63 random alpha-numeric characters
// Generate using: https://www.grc.com/passwords.htm
tokenSecret: '45E46vA3jqfqwGLfwSyFGa22dmUOvYTTxUpxk8HxqYROKQXdFrIwfeUopkSfXam'
},
common: {
/*
* tryLoginTimes is control login error times to avoid force attack.
* if value is 0, no limit for login auth, it may not safe for account. when it's a number, it means you can
* try that times today. but it need config redis server.
*/
tryLoginTimes: 0,
// CodePush Web(https://github.com/lisong/code-push-web) login address.
//codePushWebUrl: "http://localhost:3001/login",
// create patch updates's number. default value is 3
diffNums: 3,
// data dir for caclulate diff files. it's optimization.
dataDir: "/app/db/data",
// storageType which is your binary package files store. options value is ("local" | "qiniu" | "s3")
storageType: "local",
// options value is (true | false), when it's true, it will cache updateCheck results in redis.
updateCheckCache: false
},
8:
啓動數據庫mysql -u root -p
配置數據庫:
./bin/db init –dbhost localhost –dbuser root –dbpassword 123456
啓動./bin/www
客戶端配置
錯誤截圖:
1:沒有安裝unzip
yum -y install unzip
2:config.js db配置錯誤host應該爲”127.0.0.1”