Skip to content

Latest commit

 

History

History
165 lines (111 loc) · 4.09 KB

README.md

File metadata and controls

165 lines (111 loc) · 4.09 KB

INSTALL NODE AND NPM

see

(chosen latest LTS version)

INSTALL PM2

$ sudo npm i -g pm2

INSTALL MYSQL

notice. mysql8.x default auth caching_sha2_pasword not support in node-mysql2 see issue

GET nativescript-app-sync-server FROM SOURCE CODE

$ git clone https://github.com/EddyVerbruggen/nativescript-app-sync-server
$ cd nativescript-app-sync-server
$ npm i

INIT DATABASE

$ ./bin/db init --dbhost "your mysql host" --dbport "your mysql port" --dbname "codepush" --dbuser "your mysql user" --dbpassword "your mysql password"

CONFIGURE nativescript-app-sync-server

save the file config.js

Some config has to change:

  • local.storageDir change to your directory,make sure have read/write permissions.
  • local.downloadUrl replace 127.0.0.1 to your machine ip.
  • common.dataDir change to your directory,make sure have read/write permissions.
  • jwt.tokenSecret get the random string from https://www.grc.com/passwords.htm, and replace the value INSERT_RANDOM_TOKEN_KEY.
  • db config: username,password,host,port change your own's

CONFIGURE for pm2

save the file process.json

some config have to change:

  • script if you install nativescript-app-sync-server from npm use nativescript-app-sync-server, or use "your source code dir"/bin/www
  • CONFIG_FILE above config.js file path, use absolute paths.

START SERVICE

$ pm2 start process.json

RESTART SERVICE

$ pm2 restart process.json

STOP SERVICE

$ pm2 stop process.json

CHECK SERVICE IS OK

$ curl -I http://YOUR_APPSYNC_SERVER_IP:3000/

return httpCode 200 OK

HTTP/1.1 200 OK
X-DNS-Prefetch-Control: off
X-Frame-Options: SAMEORIGIN
Strict-Transport-Security: max-age=15552000; includeSubDomains
X-Download-Options: noopen
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Content-Type: text/html; charset=utf-8
Content-Length: 592
ETag: W/"250-IiCMcM1ZUFSswSYCU0KeFYFEMO8"
Date: Sat, 25 Aug 2018 15:45:46 GMT
Connection: keep-alive

Use Redis to impove concurrent and security

config redis in config.js

  • updateCheckCache
  • rolloutClientUniqueIdCache
  • tryLoginTimes

UPGRADE

$ cd /path/to/nativescript-app-sync-server
$ git pull --rebase origin master
$ ./bin/db upgrade --dbhost "your mysql host" --dbport "your mysql port"  --dbuser "your mysql user" --dbpassword "your mysql password"
# upgrade codepush database
$ pm2 restart nativescript-app-sync-server # restart service

view pm2 logs

$ pm2 ls
$ pm2 show nativescript-app-sync-server
$ tail -f "output file path"

Supported Storage modes

  • local (default)
  • qiniu (qiniu)
  • s3 (aws)
  • oss (aliyun)
  • tencentcloud

Default listen Host/Port 0.0.0.0/3000

you can change it in process.json, env: PORT,HOST

$ npm i -g nativescript-app-sync-cli
$ nativescript-app-sync login http://YOU_SERVICE_IP:3000 #login in browser account:admin password:123456

change admin password eg.

$ curl -X PATCH -H "Authorization: Bearer mytoken" -H "Accept: application/json" -H "Content-Type:application/json" -d '{"oldPassword":"123456","newPassword":"654321"}' http://YOU_SERVICE_IP:3000/users/password

Use NativeScript AppSync Web to manage apps

add codePushWebUrl config in config.js

eg.

"common": {
  "codePushWebUrl": "Your AppSync Web address",
}