Skip to content

Commit a0cdc71

Browse files
committed
Improve documentation and config files
1 parent 7fb13e0 commit a0cdc71

File tree

3 files changed

+51
-26
lines changed

3 files changed

+51
-26
lines changed

config/config.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ config.development = {
7171
},
7272
// Config for local storage when storageType value is "local".
7373
local: {
74-
// Binary files storage dir, Do not use tmpdir and it's public download dir.
74+
// Binary files storage dir, Do not use tmpdir and its public download dir.
7575
storageDir: process.env.STORAGE_DIR || os.tmpdir(),
7676
// Binary files download host address which Code Push Server listen to. the files storage in storageDir.
7777
downloadUrl:
@@ -90,26 +90,25 @@ config.development = {
9090
// determine whether new account registrations are allowed
9191
allowRegistration: toBool(process.env.ALLOW_REGISTRATION),
9292
/*
93-
* tryLoginTimes is control login error times to avoid force attack.
94-
* if value is 0, no limit for login auth, it may not safe for account. when it's a number, it means you can
95-
* try that times today. but it need config redis server.
93+
* tryLoginTimes limits login error attempts to avoid force attack.
94+
* if value is 0, no limit for login auth, it may not be safe.
95+
* when it's a number, it means you can try that many times today,
96+
* but it needs a redis server.
9697
*/
9798
tryLoginTimes: toNumber(process.env.TRY_LOGIN_TIMES, 4),
9899
// create patch updates's number. default value is 3
99100
diffNums: toNumber(process.env.DIFF_NUMS, 3),
100-
// data dir for caclulate diff files. it's optimization.
101+
// data dir to calculate diff files. it's optimization.
101102
dataDir: process.env.DATA_DIR || os.tmpdir(),
102103
// storageType which is your binary package files store. options value is ("local" | "qiniu" | "s3"| "oss" || "tencentcloud")
103104
storageType: process.env.STORAGE_TYPE || 'local',
104105
// options value is (true | false), when it's true, it will cache updateCheck results in redis.
105106
updateCheckCache: toBool(process.env.UPDATE_CHECK_CACHE),
106107
// options value is (true | false), when it's true, it will cache rollout results in redis
107108
rolloutClientUniqueIdCache: toBool(process.env.ROLLOUT_CLIENT_UNIQUE_ID_CACHE),
108-
109-
// CodePush Web(https://github.com/lisong/code-push-web) login address.
110-
//codePushWebUrl: "http://127.0.0.1:3001/login",
111109
},
112-
// Config for smtp email,register module need validate user email project source https://github.com/nodemailer/nodemailer
110+
// Config for smtp email; register module needs to validate user email
111+
// project source https://github.com/nodemailer/nodemailer
113112
smtpConfig: {
114113
host: process.env.SMTP_HOST,
115114
port: process.env.SMTP_PORT || 465,

docs/install-server.md

+40-16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## INSTALL NODE AND NPM
22

3-
[see](https://nodejs.org/en/download/)
3+
[Node Downloads](https://nodejs.org/en/download/)
44

55
> (choose latest LTS version)
66
@@ -22,7 +22,7 @@ $ sudo npm i -g pm2
2222
## GET code-push-server FROM NPM
2323

2424
```shell
25-
$ npm install @byronigoe/code-push-server@latest -g
25+
$ npm install byronigoe/code-push-server -g
2626
```
2727

2828
## GET code-push-server FROM SOURCE CODE
@@ -35,42 +35,66 @@ $ npm install
3535

3636
# GET Redis
3737

38+
```shell
39+
yum install redis.x86_64
40+
```
3841
[Redis for Windows](https://github.com/microsoftarchive/redis/releases)
3942

4043
## INIT DATABASE
4144

45+
Create a MySQL user, e.g.
4246
```shell
43-
$ code-push-server-db init --dbhost "your mysql host" --dbport "your mysql port" --dbuser "your mysql user" --dbpassword "your mysql password"
47+
CREATE USER 'codepush'@'localhost' IDENTIFIED BY 'create_a_password';
48+
```
49+
50+
Grant appropriate permissions, e.g.
51+
```shell
52+
GRANT ALL PRIVILEGES ON codepush . * TO 'codepush'@'localhost';
53+
```
54+
55+
Full command
56+
```shell
57+
$ code-push-server-db init --dbhost "your mysql host" --dbport "your mysql port" --dbname "your database" --dbuser "your mysql user" --dbpassword "your mysql password"
58+
```
59+
60+
Defaults (if omitted) are:
61+
| dbhost | localhost |
62+
| dbport | 3306 |
63+
| dbname | codepush |
64+
| dbuser | root |
65+
66+
Minimally
67+
```shell
68+
$ code-push-server-db init --dbpassword "your mysql root password"
4469
```
4570

4671
or from source code
4772

4873
```shell
49-
$ ./bin/db init --dbhost "your mysql host" --dbport "your mysql port" --dbuser "your mysql user" --dbpassword "your mysql password"
74+
$ ./bin/db init --dbhost "your mysql host" --dbport "your mysql port" --dbname "your database" --dbuser "your mysql user" --dbpassword "your mysql password"
5075
```
5176

5277
> output: success
5378
5479
## CONFIGURE for code-push-server
5580

56-
save the file [config.js](https://github.com/byronigoe/code-push-server/blob/master/config/config.js)
57-
58-
some config have to change:
81+
Save the file [config.js](https://github.com/byronigoe/code-push-server/blob/master/config/config.js) and modify the properties, or set the corresponding environment variables (e.g. in process.json).
5982

60-
- `local`.`storageDir` change to your directory,make sure have read/write permissions.
61-
- `local`.`downloadUrl` replace `127.0.0.1` to your machine ip.
62-
- `common`.`dataDir` change to your directory,make sure have read/write permissions.
63-
- `jwt`.`tokenSecret` get the random string from `https://www.grc.com/passwords.htm`, and replace the value `INSERT_RANDOM_TOKEN_KEY`.
64-
- `db` config: `username`,`password`,`host`,`port` change your own's
83+
- `local`.`storageDir` change to your directory, make sure you have read/write permissions.
84+
- `local`.`downloadUrl` replace `127.0.0.1` to your machine's IP.
85+
- `common`.`dataDir` change to your directory, make sure you have read/write permissions.
86+
- `jwt`.`tokenSecret` get a random string from `https://www.grc.com/passwords.htm`, and replace the value `INSERT_RANDOM_TOKEN_KEY`.
87+
- `db` config: `username`,`password`,`host`,`port` set the environment variables, or change them in this file.
88+
- `smtpConfig` config: `host`,`auth.user`,`auth.pass` needed if you enable `common.allowRegistration`
6589

6690
## CONFIGURE for pm2
6791

68-
save the file [process.json](https://github.com/byronigoe/code-push-server/blob/master/docs/process.json)
92+
Save the file [process.json](https://github.com/byronigoe/code-push-server/blob/master/process.json)
6993

70-
some config have to change:
94+
Some configuration properties have to change:
7195

7296
- `script` if you install code-push-server from npm use `code-push-server`, or use `"your source code dir"/bin/www`
73-
- `CONFIG_FILE` above config.js file path, use absolute path.
97+
- `CONFIG_FILE` absolute path to the config.js you downloaded.
7498

7599
## START SERVICE
76100

@@ -81,7 +105,7 @@ $ pm2 start process.json
81105
## RESTART SERVICE
82106

83107
```shell
84-
$ pm2 restart process.json
108+
$ pm2 reload process.json
85109
```
86110

87111
## STOP SERVICE

process.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"instances": "max", // Number of open instances, 'max' is the number of cpu cores
88
"exec_mode": "cluster", // Cluster mode to maximize website concurrency
99
"env": {
10-
"NODE_ENV": "production"
10+
"NODE_ENV": "production",
11+
"PORT": 3000,
12+
"CONFIG_FILE": "/path/to/config.js"
1113
}
1214
}
1315
]

0 commit comments

Comments
 (0)