codepush安装

Posted ray-mmss

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了codepush安装相关的知识,希望对你有一定的参考价值。

https://github.com/lisong/code-push-server/blob/master/docs/README.md
=====> 安装mysql
下载mysql yum repository 安装
https://dev.mysql.com/downloads/repo/yum/
yum install mysql80-community-release-el7-3.noarch.rpm
yum repolist enabled | grep "mysql.*-community.*"
yum-config-manager --enable mysql80-community
yum install mysql-community-server
systemctl start mysqld

# 取消密码强度验证
plugin-load=validate_password.so
validate-password=OFF
grep ‘temporary password‘ /var/log/mysqld.log
mysql -uroot -p
ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘codePush@365!‘;

SHOW VARIABLES LIKE ‘validate_password%‘;
set global validate_password.policy=0;
set global validate_password.length=1;
 
# 创建用户并授权
ALTER USER ‘codepush‘@‘%‘ IDENTIFIED WITH mysql_native_password BY ‘codePush@365‘
grant all privileges on *.* to ‘codepush‘@‘%‘;
flush privileges;
 
=====> 安装redis
wget http://download.redis.io/releases/redis-4.0.14.tar.gz
tar -xf redis-4.0.14.tar.gz
mv redis-4.0.14 redis
cd redis
#src/redis-server    # 启动
#./redis-cli    # 测试
#set htllo redis
#get hello
make -j 4 => (以四核方式编译源码文件)
make test -j 4 => (测试编译的源码是否有问题)
# 解决You need tcl 8.5 or newer in order to run the Redis test
wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz
tar xzvf tcl8.6.1-src.tar.gz  -C /usr/local/
cd  /usr/local/tcl8.6.1/unix/ 
./configure
make
make install
make test -j 4 => (测试编译的源码是否有问题)
make PREFIX=/redis-4.0.10 install (指定安装redis位置)
# 修改配置文件
daemonize yes
protected no
requirepass  123
port 6379
dir "数据文件的位置"
logfile "指定日志文件的位置"
# 设置开机启动
复制redis安装文件夹中的启动脚本到/etc/init.d
cp /redis-4.0.10/utils/redis_init_script /etc/init.d/redis
修改脚本
vi /etc/init.d/redis
将如下两行 = 号后面换成安装目录中对应的启动文件
EXEC=/data/apps/redis/bin/redis-server
CLIEXEC=/data/apps/redis/bin/redis-cli
CONF="/opt/software/redis-4.0.14/redis.conf"
修改权限
chmod +x /etc/init.d/redis
添加redis服务:
chkconfig --add redis
设为开机启动:
chkconfig redis on
redis启动关闭等命令
service redis start
service redis stop
ps -ef | grep redis
=====>  安装nginx
yum install -y gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
wget https://nginx.org/download/nginx-1.16.0.tar.gz
useradd -M nginx
tar -xf nginx-1.16.0.tar.gz
./configure --user=nginx --group=nginx --prefix=/data/apps/nginx --with-http_stub_status_module --with-http_ssl_module  --with-stream
make && make install
cat <<EOF > /etc/profile.d/nginx.sh
export PATH=/data/apps/nginx/sbin/:$PATH
EOF
source /etc/profile

=====> 安装codepush
cd /data/apps/
# INSTALL NODE AND NPM
yum -y install npm
# INSTALL PM2
npm i -g pm2
# GET code-push-server FROM NPM
npm install code-push-server@latest -g
# GET code-push-server FROM SOURCE CODE
git clone https://github.com/lisong/code-push-server.git
cd code-push-server
npm install
# INIT DATABASE
code-push-server-db init --dbhost localhost --dbport 3306 --dbuser "codepush" --dbpassword "codePush@365"
# ./bin/db init --dbhost localhost --dbport 3306  --dbuser "codepush" --dbpassword ‘codePush@365‘
# 修改配置文件
sed -i ‘s/null/password/‘ bin/db
# 修改 config.js     (在config/config.js下)
   qiniu:
    accessKey: "63o7v6hB_2MsY0cl9YC8eg3Gor9ytnliQV4BTacP",
    secretKey: "fRWTWY7T361WiArdHuCzBVoPvu8nUCyz-U_sOKjF",
    bucketName: "dxsp",
    downloadUrl: "http://test.dianyi125.com" // Binary files download host address.
  ,
 // 去https://www.grc.com/passwords.htm获取63 random alpha-numeric characters (a-z, A-Z, 0-9):的密钥
    jwt:
    // Recommended: 63 random alpha-numeric characters
    // Generate using: https://www.grc.com/passwords.htm
    //tokenSecret: process.env.TOKEN_SECRET ||‘INSERT_RANDOM_TOKEN_KEY‘
    tokenSecret: process.env.TOKEN_SECRET || ‘3UqxPvyAZjRXbsLuP0Hr2dcyNdaF5wTkJox3P6ogUBmCIbfoBFiUuqHsCxDm1Jl‘
  ,  

# 使用pm2管理 修改 ./docs/process.json

    "apps" : [
       
            "name"      : "code-push-server",
            "max_memory_restart" : "300M",
            "script"    : "../bin/www",
            "instances"  : "max", //开启实例数量,max为cpu核数
            "exec_mode"  : "cluster", //集群模式,最大提升网站并发
            "env" :
                "NODE_ENV" : "production",
                "PORT" : 80,
                "CONFIG_FILE" : "../config/config.js"
       
    ]

$ pm2 start process.json
//  更多 pm2 命令
$ pm2 stop [options] <id|name|all|json|stdin...>  关闭服务
$ pm2 list 查看所有
$ pm2 show <id> 查看某个服务的信息
# 普通启动
./bin/www

# CHECK SERVICE IS OK
curl -I http://103.219.30.6
# UPGRADE
npm install -g code-push-server@latest
code-push-server-db upgrade --dbhost "your mysql host" --dbport "your mysql port"  --dbuser "your mysql user" --dbpassword "your mysql password" # upgrade codepush database
pm2 restart code-push-server # restart service
# view pm2 logs
pm2 ls
pm2 show code-push-server
tail -f "output file path"
 
# mysqldump -uroot codepush > codepush.sql
create database codepush default character set utf8mb4 collate utf8mb4_unicode_ci;
# mysql -u root -p codepush < codepush.sql

以上是关于codepush安装的主要内容,如果未能解决你的问题,请参考以下文章

CodePush热更新组件详细接入教程

codePush常用

react native codepush之搭建自己的更新服务器

fatal error: 'CodePush/CodePush.h' file not found

capacitor集成codepush

sh Codepush push.sh