New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code-push-server 使用+一些需要注意的地方 #135

Open
ciuji opened this Issue Jun 13, 2018 · 5 comments

Comments

Projects
None yet
3 participants
@ciuji

ciuji commented Jun 13, 2018

Code Push Server

环境搭建

code-push-server 配置

  1. 初始化mysql数据库

    sample:

    code-push-server-db init --dbhost localhost --dbuser root --dbpassword Abc123456

    注:这里配置的东西需要在config.js中相对应。

  2. 修改code-push-server 的config.js配置

    参考config

    注意:每次修改完config之后需要重新启动code-push-server

    主要需要修改的配置项有:

    • common里面的storageType,dataDir
    • 对应的storagetype中的配置
    • 如果使用的是local,就需要修改storageDir和downloadUrl,不修改的话他就会自己创建相应文件夹,可能遇到无法创建的问题。
    • sample config.js:
      var config = {};
      config.development = {
        db: {
          username: process.env.RDS_USERNAME || "root",
          password: process.env.RDS_PASSWORD || "Abc123456",
          database: process.env.DATA_BASE || "codepush",
          host: process.env.RDS_HOST || "127.0.0.1",
          port: process.env.RDS_PORT || 3306,
          dialect: "mysql",
          logging: false
        },
        local: {
          storageDir: "/Users/i348909/tablee/workspaces/storage",
          downloadUrl: "http://10.130.229.22:3000/download",
          public: '/download'
        },
        common: {
          tryLoginTimes: 0,
          diffNums: 3,
          dataDir: "/Users/i348909/tablee/workspaces/data",
          storageType:  "local",
          updateCheckCache: false
        },
      config.development.log4js = {
        appenders: {console: { type: 'console'}},
        categories : {
          "default": { appenders: ['console'], level:'error'},
          "startup": { appenders: ['console'], level:'info'},
          "http": { appenders: ['console'], level:'info'}
        }
      }
      
      config.production = Object.assign({}, config.development);
      module.exports = config;
  3. 启动code-push-server

    code-push-server

code-push 配置

  1. 在code-push中登陆到code-push-server

    sample:

    code-push login 127.0.0.1:3000

    初始用户名:admin,初始密码:123456

    获取token后复制到命令行中,即可成功登陆。

  2. 在code-push中添加app

    sample:

    code-push app add CodePushDemo-andrioid android react-native

    注:android和ios需要分别添加

  3. 获取Deployment Key或查看Deployment Key

    sample:

    code-push deployment list CodePushDemo-android -k

    注:有两个key,分别是Staging环境和Production环境。

react-native项目配置和发布

  1. 修改info.plist和MainApplication.java

    这是应用配置最重要的地方,也是与使用微软的react-native-code-push不一样的地方,需要添加"YourCodePushServerUrl"来指向自己的服务器

    参考config react-native project

    sample:

    Android 修改 MainApplication.java 如下

    @Override
    protected List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
        new MainReactPackage(),
        new CodePush(
          "l373MdjxhXA0KNikVY6akGUvZwMF4ksvOXqog",
          MainApplication.this,
          BuildConfig.DEBUG,
          "http://10.130.229.22:3000"
          )
    );
    }
  2. 发布应用

    sample:

    code-push release-react CodePushDemo-android android
  3. 注意

    使用code-push要参考正确使用热更新

    !!!使用热更新,每次修改只需要修改js文件,然后就可以使用code-push发布了,不需要修改build.gradle中的版本号.如果修改了java或者objective-c,就不能使用热更新,必须重新发布。

可参考的详细流程

code-push和code-push-server

React Native应用部署/热更新-CodePush最新集成总结(新)

@CveniEs

This comment has been minimized.

CveniEs commented Nov 5, 2018

请问我在初始化mysql的时候,想将数据库部署在其他的服务器上,该怎么去写命令呢?

@ciuji

This comment has been minimized.

ciuji commented Nov 5, 2018

请问我在初始化mysql的时候,想将数据库部署在其他的服务器上,该怎么去写命令呢?

@CveniEs 不好意思,这个我就没有尝试过了。

@wlxscn

This comment has been minimized.

wlxscn commented Dec 2, 2018

请问一下code-push的更新策略,我看源代码里只能查到当前app版本对应的package,所以上传新的package之后,app并不会检测到有新的package。我现在会手动更改数据库当前app版本对应的package版本,这样的才会更新。

@ciuji

This comment has been minimized.

ciuji commented Dec 3, 2018

@wlxscn 建议去提出新的issue,这个是我几个月前操作的时候写的文档了,我自己也记得不是很清楚了。但按照我的记忆来说,app应该会自动检测到新的package的,不知道您是bug还是配置错误了。

@wlxscn

This comment has been minimized.

wlxscn commented Dec 5, 2018

@ciuji 不好意思,是我代码的原因,已经解决了,谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment