refactor(pm2): restructure our pm2 configs

why: several reasons...

- to have a unified approach and pattern for:
  - debugging
  - fs watching for local dev
  - running services in dev
  - configuring services in dev

- to improve the initial clone and subsequent `npm ci` experience
- to make future work on tooling easier
This commit is contained in:
Danny Coates 2020-04-12 16:54:49 -07:00
Родитель a4b3996349
Коммит 3a054dfc3f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4C442633C62E00CB
61 изменённых файлов: 17834 добавлений и 1210 удалений

Просмотреть файл

@ -1,131 +0,0 @@
{
"apps": [
{
"name": "auth-server local mail helper",
"script": "test/mail_helper.js",
"cwd": "packages/fxa-auth-server",
"env": {
"NODE_ENV": "dev"
},
"max_restarts": "1",
"min_uptime": "2m"
},
{
"name": "auth-server db mysql PORT 8000",
"script": "../../_scripts/start-after-mysql.sh",
"cwd": "packages/fxa-auth-db-mysql",
"env": {
"NODE_ENV": "dev"
},
"max_restarts": "2",
"min_uptime": "2m"
},
{
"name": "auth-server key server PORT 9000",
"script": "../../_scripts/start-after-mysql.sh",
"cwd": "packages/fxa-auth-server",
"env": {
"DB": "mysql",
"NODE_ENV": "dev",
"IP_ADDRESS": "0.0.0.0",
"SIGNIN_UNBLOCK_FORCED_EMAILS": "^block.*@restmail\\.net$",
"SIGNIN_CONFIRMATION_ENABLED": "true",
"SIGNIN_CONFIRMATION_FORCE_EMAIL_REGEX": "^sync.*@restmail\\.net$"
},
"max_restarts": "1",
"min_uptime": "2m"
},
{
"name": "content-server PORT 3030",
"script": "node_modules/.bin/grunt",
"args": ["server"],
"cwd": "packages/fxa-content-server",
"env": {
"NODE_ENV": "development"
},
"max_restarts": "1",
"min_uptime": "2m"
},
{
"name": "profile-server PORT 1111",
"script": "../../_scripts/start-after-mysql.sh",
"cwd": "packages/fxa-profile-server",
"max_restarts": "1",
"env": {
"NODE_ENV": "development",
"HOST": "0.0.0.0",
"DB": "mysql"
},
"min_uptime": "2m"
},
{
"name": "browserid-verifier PORT 5050",
"script": "server.js",
"cwd": "packages/browserid-verifier",
"env": {
"PORT": "5050",
"IP_ADDRESS": "0.0.0.0",
"FORCE_INSECURE_LOOKUP_OVER_HTTP": "true"
},
"max_restarts": "1",
"min_uptime": "2m"
},
{
"name": "payments server PORT 3031",
"cwd": "packages/fxa-payments-server",
"script": "npm",
"args": ["run", "start-dev"],
"max_restarts": "1",
"min_uptime": "2m",
"env": {
"LOGGING_FORMAT": "pretty",
"NODE_ENV": "development"
}
},
{
"name": "support admin panel PORT 7100",
"cwd": "packages/fxa-support-panel",
"script": "npm",
"args": ["run", "start-dev"],
"max_restarts": "1",
"min_uptime": "2m",
"env": {
"LOGGING_FORMAT": "pretty",
"NODE_ENV": "development"
}
},
{
"name": "event-broker",
"script": "../../_scripts/start-after-mysql.sh",
"cwd": "packages/fxa-event-broker",
"max_restarts": "1",
"env": {
"NODE_ENV": "development",
"WORKER_HOST": "0.0.0.0"
},
"min_uptime": "2m"
},
{
"name": "123done PORT 8080",
"script": "server.js",
"cwd": "packages/123done",
"max_restarts": "1",
"env": {
"CONFIG_123DONE": "./config-local.json",
"NODE_ENV": "dev"
},
"min_uptime": "2m"
},
{
"name": "321done UNTRUSTED PORT 10139",
"script": "server.js",
"cwd": "packages/123done",
"max_restarts": "1",
"env": {
"CONFIG_123DONE": "./config-local-untrusted.json",
"NODE_ENV": "dev"
},
"min_uptime": "2m"
}
]
}

4
.gitignore поставляемый
Просмотреть файл

@ -61,9 +61,13 @@ Thumbs.db
!.nsprc
!.sass-lint.yml
!.prettier*
!.vscode
## Package-specific ##
# circleci
.circleci/local.yml
# browserid-verifier
packages/browserid-verifier/loadtest/venv
packages/browserid-verifier/loadtest/*.pyc

26
.vscode/launch.json поставляемый
Просмотреть файл

@ -18,7 +18,7 @@
"request": "attach",
"skipFiles": ["<node_internals>/**"],
"cwd": "${workspaceFolder}",
"port": 9229
"port": 9130
},
{
"name": "Attach to broker",
@ -35,6 +35,30 @@
"skipFiles": ["<node_internals>/**"],
"cwd": "${workspaceFolder}",
"port": 9170
},
{
"name": "Attach to support",
"type": "node",
"request": "attach",
"skipFiles": ["<node_internals>/**"],
"cwd": "${workspaceFolder}",
"port": 9190
},
{
"name": "Attach to admin",
"type": "node",
"request": "attach",
"skipFiles": ["<node_internals>/**"],
"cwd": "${workspaceFolder}",
"port": 9140
},
{
"name": "Attach to admin-server",
"type": "node",
"request": "attach",
"skipFiles": ["<node_internals>/**"],
"cwd": "${workspaceFolder}",
"port": 9150
}
]
}

Просмотреть файл

@ -251,32 +251,23 @@ We have also extensively documented working with the [FxA code-base using VS Cod
#### Debugging a server
In the case of Firefox Accounts, the `pm2` process manager complicates setup a bit. Here's one approach that works:
`npm start` runs some of the services with the debugger enabled by default.
1. Start the whole server as usual (`npm install && npm start` from top-level in the monorepo)
2. Stop the pm2-managed version of whatever server you care about:
- Get the pm2 `id` for the server from `./pm2 ls`
- Stop the process by doing `./pm2 stop NN` where NN is the pm2 `id`
3. Restart the server manually, passing the `--inspect` argument:
- For fxa-content-server, fxa-payments-server, fxa-auth-server, or fxa-event-broker, just go to the package directory and do `npm run start-dev-debug` to start a debuggable server process.
- For other servers, we just haven't added a `start-dev-debug` run script yet; feel free to add one by tracing through the existing run scripts to find the actual script that runs the server (not one that forks another script).
4. Connect to the process to debug it:
2. To see which debug port each service is listening on check `.vscode/launch.json` or the `pm2.config.js` file of the package you're interested in.
3. Connect to the process to debug it:
- Using Google Chrome, go to `chrome://inspect`, then click the process to connect to devtools.
- you may need to add a new target in the "Configure..." menu with the correct debug port
- VSCode requires setting up a `.vscode/launch.json` file; see the [VSCode docs](https://code.visualstudio.com/docs/nodejs/nodejs-debugging) for details.
Alternatively if you want to be able to debug any of several servers that is configured with a `start-dev-debug` script you can run this from the base fxa directory:
```bash
npm start debug
```
##### Default Debug Ports
If you're using `npm start debug`, the following ports are used for `--inspect`:
If you're using `npm start`, the following ports are used for `--inspect`:
| Port | Service |
| ---- | --------------- |
| 9140 | content-server |
| 9130 | content-server |
| 9140 | admin-panel |
| 9150 | admin-server |
| 9160 | auth-server |
| 9170 | payments-server |

Просмотреть файл

@ -0,0 +1,73 @@
module.exports = {
apps: [
{
name: "mysql",
script: "_scripts/mysql.sh",
max_restarts: "1",
min_uptime: "2m",
kill_timeout: 20000
},
{
name: "redis",
script: "_scripts/redis.sh",
env: {
PORT: "6379"
},
max_restarts: "1",
min_uptime: "2m",
kill_timeout: 20000
},
{
name: "memcache",
script: "_scripts/memcached.sh",
max_restarts: "1",
min_uptime: "2m",
kill_timeout: 20000
},
{
name: "sns",
script: "_scripts/goaws.sh",
max_restarts: "1",
min_uptime: "2m",
autorestart: false,
kill_timeout: 20000
},
{
name: "pubsub",
script: "_scripts/pubsub.sh",
max_restarts: "1",
min_uptime: "2m",
kill_timeout: 20000
},
{
name: "firestore",
script: "_scripts/firestore.sh",
max_restarts: "1",
min_uptime: "2m",
kill_timeout: 20000
},
{
name: "sync",
script: "_scripts/syncserver.sh",
max_restarts: "1",
min_uptime: "2m",
autorestart: false,
kill_timeout: 20000
},
{
name: "pushbox",
script: "_scripts/pushbox.sh",
max_restarts: "1",
min_uptime: "2m",
args: "3306 root@mydb:3306",
kill_timeout: 20000
},
{
name: "email",
script: "_scripts/fxa-email-service.sh",
max_restarts: "1",
min_uptime: "2m",
kill_timeout: 20000
}
]
};

Просмотреть файл

@ -1,66 +0,0 @@
{
"apps": [
{
"name": "mysql",
"script": "_scripts/mysql.sh",
"max_restarts": "1",
"min_uptime": "2m",
"kill_timeout": 20000
},
{
"name": "redis",
"script": "_scripts/redis.sh",
"env": {
"PORT": "6379"
},
"max_restarts": "1",
"min_uptime": "2m",
"kill_timeout": 20000
},
{
"name": "memcache",
"script": "_scripts/memcached.sh",
"max_restarts": "1",
"min_uptime": "2m",
"kill_timeout": 20000
},
{
"name": "sns",
"script": "_scripts/goaws.sh",
"max_restarts": "1",
"min_uptime": "2m",
"autorestart": false,
"kill_timeout": 20000
},
{
"name": "pubsub",
"script": "_scripts/pubsub.sh",
"max_restarts": "1",
"min_uptime": "2m",
"kill_timeout": 20000
},
{
"name": "firestore",
"script": "_scripts/firestore.sh",
"max_restarts": "1",
"min_uptime": "2m",
"kill_timeout": 20000
},
{
"name": "sync",
"script": "_scripts/syncserver.sh",
"max_restarts": "1",
"min_uptime": "2m",
"autorestart": false,
"kill_timeout": 20000
},
{
"name": "pushbox",
"script": "_scripts/pushbox.sh",
"max_restarts": "1",
"min_uptime": "2m",
"args": "3306 root@mydb:3306",
"kill_timeout": 20000
}
]
}

Просмотреть файл

@ -1,151 +0,0 @@
{
"apps": [
{
"name": "email",
"script": "_scripts/fxa-email-service.sh",
"max_restarts": "1",
"min_uptime": "2m",
"kill_timeout": 20000
},
{
"name": "inbox",
"script": "test/mail_helper.js",
"cwd": "packages/fxa-auth-server",
"env": {
"NODE_ENV": "dev"
},
"max_restarts": "1",
"min_uptime": "2m"
},
{
"name": "auth-db",
"script": "../../_scripts/start-after-mysql.sh",
"cwd": "packages/fxa-auth-db-mysql",
"env": {
"NODE_ENV": "dev"
},
"max_restarts": "2",
"min_uptime": "2m"
},
{
"name": "auth",
"script": "../../_scripts/start-after-mysql-debug.sh",
"cwd": "packages/fxa-auth-server",
"env": {
"DB": "mysql",
"NODE_ENV": "dev",
"IP_ADDRESS": "0.0.0.0",
"SIGNIN_UNBLOCK_FORCED_EMAILS": "^block.*@restmail\\.net$",
"SIGNIN_CONFIRMATION_ENABLED": "true",
"SIGNIN_CONFIRMATION_FORCE_EMAIL_REGEX": "^sync.*@restmail\\.net$",
"CONFIG_FILES": "config/secrets.json"
},
"max_restarts": "1",
"min_uptime": "2m"
},
{
"name": "content",
"script": "npm",
"args": ["run", "start-dev-debug"],
"cwd": "packages/fxa-content-server",
"env": {
"NODE_ENV": "development"
},
"max_restarts": "1",
"min_uptime": "2m"
},
{
"name": "profile",
"script": "../../_scripts/start-after-mysql.sh",
"cwd": "packages/fxa-profile-server",
"max_restarts": "1",
"env": {
"NODE_ENV": "development",
"HOST": "0.0.0.0",
"DB": "mysql"
},
"min_uptime": "2m"
},
{
"name": "fortress",
"script": "server.js",
"cwd": "packages/fortress",
"max_restarts": "1",
"env": {
"CONFIG_FORTRESS": "./config-local.json",
"NODE_ENV": "dev"
},
"min_uptime": "2m"
},
{
"name": "123done",
"script": "server.js",
"cwd": "packages/123done",
"max_restarts": "1",
"env": {
"CONFIG_123DONE": "./config-local.json",
"NODE_ENV": "dev"
},
"min_uptime": "2m"
},
{
"name": "321done",
"script": "server.js",
"cwd": "packages/123done",
"max_restarts": "1",
"env": {
"CONFIG_123DONE": "./config-local-untrusted.json",
"NODE_ENV": "dev"
},
"min_uptime": "2m"
},
{
"name": "browserid",
"script": "server.js",
"cwd": "packages/browserid-verifier",
"env": {
"PORT": "5050",
"IP_ADDRESS": "0.0.0.0",
"FORCE_INSECURE_LOOKUP_OVER_HTTP": "true"
},
"max_restarts": "1",
"min_uptime": "2m"
},
{
"name": "payments",
"cwd": "packages/fxa-payments-server",
"script": "npm",
"args": ["run", "start-dev-debug"],
"max_restarts": "1",
"min_uptime": "2m",
"env": {
"LOGGING_FORMAT": "pretty",
"NODE_ENV": "development",
"CONFIG_FILES": "server/config/secrets.json"
}
},
{
"name": "support",
"cwd": "packages/fxa-support-panel",
"script": "npm",
"args": ["run", "start-dev"],
"max_restarts": "1",
"min_uptime": "2m",
"env": {
"LOGGING_FORMAT": "pretty",
"NODE_ENV": "development"
}
},
{
"name": "event-broker",
"script": "../../_scripts/start-after-mysql-debug.sh",
"cwd": "packages/fxa-event-broker",
"max_restarts": "1",
"env": {
"NODE_ENV": "development",
"WORKER_HOST": "0.0.0.0"
},
"min_uptime": "2m"
}
]
}

Просмотреть файл

@ -8,7 +8,7 @@ if [ "${SKIP_PACKAGES}" != "true" ]; then
# it seems the filesystem on circleci can't handle full concurrency
npx lerna exec --concurrency 6 --ignore fxa-amplitude-send -- npm ci
else
npx lerna bootstrap
npx lerna bootstrap --hoist pm2
fi
ln -sf node_modules/.bin/pm2 pm2

13
_scripts/pm2-all.sh Executable file
Просмотреть файл

@ -0,0 +1,13 @@
#!/bin/bash -e
DIR=$(dirname "$0")
COMMAND=$1
cd "$DIR"
echo "running ${COMMAND} fxa services..."
for d in ../packages/*/ ; do
if [[ -r "${d}pm2.config.js" ]]; then
(cd "$d" && npm "$COMMAND" > /dev/null)
fi
done
pm2 ls

Просмотреть файл

@ -1,3 +0,0 @@
#!/bin/bash -ex
"${0%/*}/check-mysql.sh"
npm run start-dev-debug

Просмотреть файл

@ -1,5 +0,0 @@
#!/bin/bash -ex
"${0%/*}/check-mysql.sh"
npm start

6
package-lock.json сгенерированный
Просмотреть файл

@ -6662,6 +6662,12 @@
"resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
"integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM="
},
"json": {
"version": "9.0.6",
"resolved": "https://registry.npmjs.org/json/-/json-9.0.6.tgz",
"integrity": "sha1-eXLCpaSKQmeNsnMMfCxO5uTiRYU=",
"dev": true
},
"json-parse-better-errors": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz",

Просмотреть файл

@ -2,19 +2,20 @@ module.exports = {
scripts: {
default: "nps help",
start: {
default:
"pm2 start _dev/pm2/infrastructure.json _dev/pm2/services.json && echo \"Use 'npm stop' to stop all the servers\"",
infrastructure: "pm2 start _dev/pm2/infrastructure.json",
services: "pm2 start _dev/pm2/services.json",
default: `pm2 start _dev/pm2/infrastructure.config.js && _scripts/pm2-all.sh start && echo "Use 'npm stop' to stop all the servers"`,
infrastructure: `pm2 start _dev/pm2/infrastructure.config.js`,
services: `_scripts/pm2-all.sh start`,
firefox: "./packages/fxa-dev-launcher/bin/fxa-dev-launcher &"
},
stop: {
default: "pm2 kill",
services: "pm2 stop _dev/pm2/services.json"
infrastructure: `pm2 stop _dev/pm2/infrastructure.config.js`,
services: `_scripts/pm2-all.sh stop`
},
restart: {
default: "pm2 restart all",
services: "pm2 restart _dev/pm2/services.json"
infrastructure: `pm2 restart _dev/pm2/infrastructure.config.js`,
services: `_scripts/pm2-all.sh restart`
}
}
};

Просмотреть файл

@ -12,7 +12,8 @@
"adb-reverse": "./_scripts/adb-reverse.sh",
"test": "_scripts/test-package.sh",
"config-fxios": "node _scripts/config-fxios.js",
"format": "lerna run format"
"format": "lerna run format",
"ports": "pm2 jlist | json -d'\t' -a -c 'this.pm2_env.env.PORT' pm2_env.env.PORT name"
},
"homepage": "https://github.com/mozilla/fxa",
"bugs": {
@ -88,6 +89,7 @@
"devDependencies": {
"eslint": "^6.8.0",
"eslint-plugin-fxa": "^2.0.2",
"eslint-plugin-jest": "^23.8.2"
"eslint-plugin-jest": "^23.8.2",
"json": "^9.0.6"
}
}

Просмотреть файл

@ -1,5 +1,4 @@
{
"port": 10139,
"cookieName": "321done",
"client_id": "325b4083e32fe8e7",
"client_secret": "a084f4c36501ea1eb2de33258421af97b2e67ffbe107d2812f4a14f3579900ef",

1455
packages/123done/package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -38,6 +38,7 @@
"eslint": "6.6.0",
"eslint-plugin-fxa": "2.0.1",
"npm-run-all": "4.1.5",
"pm2": "^4.2.3",
"prettier": "1.18.2"
},
"scripts": {
@ -45,7 +46,9 @@
"audit": "npm audit --json | audit-filter --nsp-config=.nsprc --audit=-",
"lint:eslint": "eslint .",
"postinstall": "bower install --config.interactive=false -s",
"start": "node server.js",
"start": "pm2 start pm2.config.js",
"stop": "pm2 stop pm2.config.js",
"restart": "pm2 restart pm2.config.js",
"test": "npm run lint",
"format": "prettier '**' --write"
}

Просмотреть файл

@ -0,0 +1,32 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
module.exports = {
apps: [
{
name: '123done',
script: 'server.js',
cwd: __dirname,
max_restarts: '1',
env: {
CONFIG_123DONE: './config-local.json',
NODE_ENV: 'dev',
PORT: '8080',
},
min_uptime: '2m',
},
{
name: '321done',
script: 'server.js',
cwd: __dirname,
max_restarts: '1',
env: {
CONFIG_123DONE: './config-local-untrusted.json',
NODE_ENV: 'dev',
PORT: '10139',
},
min_uptime: '2m',
},
],
};

1349
packages/browserid-verifier/package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -34,6 +34,7 @@
"eslint-plugin-fxa": "2.0.1",
"mocha": "5.2.0",
"npm-run-all": "4.1.5",
"pm2": "^4.2.3",
"prettier": "1.18.2",
"request": "2.88.0",
"should": "13.2.3",
@ -46,6 +47,9 @@
"lint:eslint": "eslint .",
"pretest": "npm run lint",
"test": "mocha --exit -t 5000 -R spec tests/*.js",
"format": "prettier '**' --write"
"format": "prettier '**' --write",
"start": "pm2 start pm2.config.js",
"stop": "pm2 stop pm2.config.js",
"restart": "pm2 restart pm2.config.js"
}
}

Просмотреть файл

@ -0,0 +1,20 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
module.exports = {
apps: [
{
name: 'browserid',
script: 'server.js',
cwd: __dirname,
env: {
PORT: '5050',
IP_ADDRESS: '0.0.0.0',
FORCE_INSECURE_LOOKUP_OVER_HTTP: 'true',
},
max_restarts: '1',
min_uptime: '2m',
},
],
};

1473
packages/fortress/package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -34,6 +34,7 @@
"eslint": "6.6.0",
"eslint-plugin-fxa": "2.0.1",
"npm-run-all": "4.1.5",
"pm2": "^4.2.3",
"prettier": "1.18.2"
},
"scripts": {
@ -41,7 +42,9 @@
"audit": "npm audit --json | audit-filter --nsp-config=.nsprc --audit=-",
"lint:eslint": "eslint .",
"postinstall": "bower install --config.interactive=false -s",
"start": "node server.js",
"start": "pm2 start pm2.config.js",
"stop": "pm2 stop pm2.config.js",
"restart": "pm2 restart pm2.config.js",
"test": "npm run lint",
"format": "prettier '**' --write"
}

Просмотреть файл

@ -0,0 +1,20 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
module.exports = {
apps: [
{
name: 'fortress',
script: 'server.js',
cwd: __dirname,
max_restarts: '1',
env: {
CONFIG_FORTRESS: './config-local.json',
NODE_ENV: 'dev',
PORT: '9292',
},
min_uptime: '2m',
},
],
};

Просмотреть файл

@ -1,5 +0,0 @@
# The express server started by server/bin/fxa-admin-panel.ts runs at this port:
PUBLIC_URL=http://127.0.0.1:8091
# Then it proxies to this port, where the "react-scripts start" (webpack dev server) runs:
PORT=8092
BROWSER=none

1123
packages/fxa-admin-panel/package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -3,10 +3,9 @@
"version": "0.1.0",
"description": "FxA Admin Panel",
"scripts": {
"start": "ts-node -P server/tsconfig.json server/bin/fxa-admin-panel.ts",
"start-dev": "NODE_ENV=development npm-run-all --parallel server:proxy server:react-scripts",
"server:proxy": "PROXY_STATIC_RESOURCES_FROM='http://127.0.0.1:8092' ts-node -P server/tsconfig.json server/bin/fxa-admin-panel.ts",
"server:react-scripts": "react-scripts start",
"start": "pm2 start pm2.config.js",
"stop": "pm2 stop pm2.config.js",
"restart": "pm2 restart pm2.config.js",
"lint:eslint": "eslint .",
"build": "npm-run-all build:client build:server",
"build:client": "react-scripts build",
@ -74,6 +73,7 @@
"eslint-plugin-fxa": "^2.0.1",
"eslint-plugin-jest": "^23.8.1",
"eslint-plugin-react": "^7.18.3",
"pm2": "^4.2.3",
"prettier": "^1.19.1",
"supertest": "^4.0.2",
"ts-jest": "^25.2.1",

Просмотреть файл

@ -0,0 +1,36 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
module.exports = {
apps: [
{
name: 'admin',
cwd: __dirname,
script: 'ts-node -P server/tsconfig.json server/bin/fxa-admin-panel.ts',
max_restarts: '1',
min_uptime: '2m',
env: {
LOGGING_FORMAT: 'pretty',
NODE_ENV: 'development',
NODE_OPTIONS: '--inspect=9140',
PROXY_STATIC_RESOURCES_FROM: 'http://127.0.0.1:8092',
CONFIG_FILES: 'config/secrets.json',
PORT: '8091',
},
},
{
name: 'admin-react',
cwd: __dirname,
script: 'react-scripts start',
max_restarts: '1',
min_uptime: '2m',
env: {
NODE_ENV: 'development',
PUBLIC_URL: 'http://127.0.0.1:8091',
BROWSER: 'NONE',
PORT: '8092',
},
},
],
};

1649
packages/fxa-admin-server/package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -8,11 +8,11 @@
"audit": "npm audit --json | audit-filter --nsp-config=.nsprc --audit=-",
"lint:tslint": "./node_modules/tslint/bin/tslint -p .",
"watch": "tsc -w",
"start-dev": "NODE_ENV=development ts-node-dev ./src/bin/main.ts",
"start-dev-debug": "NODE_ENV=development ts-node-dev --inspect=0.0.0.0:9150 -- ./src/bin/main.ts",
"start": "pm2 start pm2.config.js",
"stop": "pm2 stop pm2.config.js",
"restart": "pm2 restart pm2.config.js",
"test": "./node_modules/mocha/bin/mocha -r ts-node/register src/test/**/*.spec.ts src/test/**/**/*.spec.ts src/test/**/**/**/*.spec.ts",
"debug": "NODE_ENV=development nodemon --watch ./dist --inspect=0.0.0.0:5860 --nolazy ./dist/bin/main.js",
"email-bounce": "ts-node-dev ./scripts/email-bounce.ts"
"email-bounce": "ts-node ./scripts/email-bounce.ts"
},
"repository": {
"type": "git",
@ -61,11 +61,12 @@
"mocha": "^7.1.0",
"nodemon": "^2.0.2",
"npm-run-all": "^4.1.5",
"pm2": "^4.2.3",
"prettier": "^1.19.1",
"proxyquire": "^2.1.3",
"sinon": "^9.0.1",
"supertest": "^4.0.2",
"ts-node-dev": "^1.0.0-pre.44",
"ts-node": "^8.8.2",
"ts-sinon": "^1.0.25",
"tslint": "^6.1.0",
"tslint-config-prettier": "^1.18.0",

Просмотреть файл

@ -0,0 +1,23 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
module.exports = {
apps: [
{
name: 'admin-server',
script: 'ts-node src/bin/main.ts',
cwd: __dirname,
max_restarts: '1',
min_uptime: '2m',
env: {
NODE_ENV: 'development',
NODE_OPTIONS: '--inspect=9150',
TS_NODE_TRANSPILE_ONLY: 'true',
TS_NODE_FILES: 'true',
PORT: '8090' // TODO: this needs to get added to src/config.ts
},
watch: ['src']
}
]
};

Просмотреть файл

@ -93,7 +93,6 @@ envConfig = `${envConfig},${process.env.CONFIG_FILES || ''}`;
const files = envConfig.split(',').filter(fs.existsSync);
conf.loadFile(files);
conf.validate({ allowed: 'strict' });
const Config = conf;
export default Config;

1428
packages/fxa-auth-db-mysql/package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -15,7 +15,10 @@
"lint": "npm-run-all --parallel lint:*",
"audit": "npm audit --json | audit-filter --nsp-config=.nsprc --audit=-",
"lint:eslint": "eslint .",
"start": "node ./bin/db_patcher.js >/dev/null && node ./bin/server.js",
"prestart": "../../_scripts/check-mysql.sh && node ./bin/db_patcher.js >/dev/null",
"start": "pm2 start pm2.config.js",
"stop": "pm2 stop pm2.config.js",
"restart": "pm2 restart pm2.config.js",
"test": "npm run test-mysql && npm run test-server && npm run lint",
"test-mysql": "node ./bin/db_patcher.js >/dev/null && ./scripts/mocha-coverage.js test/backend test/local --exit",
"test-server": "./scripts/mocha-coverage.js db-server/test/local --exit",
@ -50,6 +53,7 @@
"nock": "8.0.0",
"npm-run-all": "4.1.5",
"nyc": "^14.1.1",
"pm2": "^4.2.3",
"prettier": "1.18.2",
"proxyquire": "1.7.10",
"restify-clients": "^2.6.7",

Просмотреть файл

@ -0,0 +1,19 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
module.exports = {
apps: [
{
name: 'auth-db',
script: './bin/server.js',
cwd: __dirname,
env: {
NODE_ENV: 'dev',
PORT: '8000',
},
max_restarts: '2',
min_uptime: '2m',
},
],
};

1158
packages/fxa-auth-server/package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -14,8 +14,10 @@
"audit": "npm audit --json | audit-filter --nsp-config=.nsprc --audit=-",
"lint:eslint": "eslint .",
"postinstall": "scripts/download_l10n.sh",
"start": "npm run gen-keys && node ./bin/key_server.js",
"start-dev-debug": "NODE_ENV=dev nodemon --inspect=0.0.0.0:9160 ./bin/key_server.js",
"prestart": "NODE_ENV=dev npm run gen-keys && ../../_scripts/check-mysql.sh",
"start": "pm2 start pm2.config.js",
"stop": "pm2 stop pm2.config.js",
"restart": "pm2 restart pm2.config.js",
"test": "VERIFIER_VERSION=0 scripts/test-local.sh",
"test-ci": "npm run gen-keys && scripts/test-local.sh && npm run test-e2e",
"test-e2e": "NODE_ENV=dev mocha test/e2e",
@ -133,6 +135,7 @@
"nodemon": "^2.0.3",
"npm-run-all": "4.1.5",
"nyc": "^14.1.1",
"pm2": "^4.2.3",
"prettier": "^1.18.2",
"proxyquire": "2.0.0",
"read": "1.0.7",

Просмотреть файл

@ -0,0 +1,38 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
module.exports = {
apps: [
{
name: 'auth',
script: './bin/key_server.js',
cwd: __dirname,
env: {
DB: 'mysql',
NODE_ENV: 'dev',
NODE_OPTIONS: '--inspect=9160',
IP_ADDRESS: '0.0.0.0',
SIGNIN_UNBLOCK_FORCED_EMAILS: '^block.*@restmail\\.net$',
SIGNIN_CONFIRMATION_ENABLED: 'true',
SIGNIN_CONFIRMATION_FORCE_EMAIL_REGEX: '^sync.*@restmail\\.net$',
CONFIG_FILES: 'config/secrets.json',
PORT: '9000',
},
watch: ['bin', 'config', 'lib'],
max_restarts: '1',
min_uptime: '2m',
},
{
name: 'inbox',
script: 'test/mail_helper.js',
cwd: __dirname,
env: {
NODE_ENV: 'dev',
MAILER_PORT: '9001',
},
max_restarts: '1',
min_uptime: '2m',
},
],
};

Просмотреть файл

@ -16,6 +16,8 @@ DEFAULT_ARGS="--recursive --timeout 5000 --exit"
./scripts/gen_vapid_keys.js
./scripts/oauth_gen_keys.js
node ../fxa-auth-db-mysql/bin/db_patcher > /dev/null
npm run lint:eslint
grunt copyright
GLOB=$*
if [ -z "$GLOB" ]; then
@ -34,6 +36,3 @@ if [ -z "$GLOB" ]; then
else
./scripts/mocha-coverage.js $DEFAULT_ARGS $GLOB
fi
npm run lint:eslint
grunt copyright

1293
packages/fxa-content-server/package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -8,8 +8,10 @@
"lint": "npm-run-all --parallel lint:*",
"audit": "npm audit --json | audit-filter --nsp-config=.nsprc --audit=-",
"lint:eslint": "eslint app server tests --cache",
"start": "node scripts/check-local-config && grunt server",
"start-dev-debug": "node scripts/check-local-config && node --inspect server/bin/fxa-content-server.js",
"prestart": "node scripts/check-local-config && grunt l10n-create-json l10n-generate-tos-pp:app",
"start": "pm2 start pm2.config.js",
"stop": "pm2 stop pm2.config.js",
"restart": "pm2 restart pm2.config.js",
"start-production": "NODE_ENV=production grunt build && CONFIG_FILES=server/config/local.json,server/config/production.json grunt serverproc:dist",
"start-remote": "scripts/run_remote_dev.sh",
"test": "node tests/intern.js --unit=true",
@ -150,6 +152,7 @@
"jsqr": "1.2.0",
"npm-run-all": "4.1.5",
"otplib": "7.1.0",
"pm2": "^4.2.3",
"prettier": "^1.18.2",
"proxyquire": "1.7.4",
"request": "2.88.0",

Просмотреть файл

@ -0,0 +1,21 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
module.exports = {
apps: [
{
name: 'content',
script: 'node --inspect=9130 server/bin/fxa-content-server.js',
cwd: __dirname,
env: {
NODE_ENV: 'development',
CONFIG_FILES: 'server/config/local.json',
PORT: 3030,
},
watch: ['server'],
max_restarts: '1',
min_uptime: '2m',
},
],
};

Просмотреть файл

@ -2,28 +2,6 @@
DIR=$(dirname "$0")
# copied from /test/curl.sh
function check() {
# Real startup of the servers takes longer than `pm start`.
# In order to check their urls, we have to wait for them (2 minutes) and periodically
# check if their endpoints are available.
# Function takes following parameters:
# * $1 - an url of an endpoint to check
# * $2 [optional] - expected status code of a response from this endpoint. Defaults to 200.
RETRY=12
for i in $(eval echo "{1..$RETRY}"); do
if [ "$(curl -s -o /dev/null --silent -w "%{http_code}" http://$1)" == "${2:-200}" ]; then
return
else
if [ "$i" -lt $RETRY ]; then
sleep 10
fi
fi
done
exit 1
}
function test_suite() {
local suite=$1
local numGroups=6
@ -44,15 +22,26 @@ cp ../version.json config
npm run lint
cd ../../
npx pm2 start .circleci/pm2.json
npx lerna run start \
--scope "123done" \
--scope "browserid-verifier" \
--scope "fxa-auth-db-mysql" \
--scope "fxa-auth-server" \
--scope "fxa-content-server" \
--scope "fxa-payments-server" \
--scope "fxa-profile-server" \
--scope "fxa-support-panel" \
--concurrency 1 > /dev/null
npx pm2 ls
# ensure email-service is ready
_scripts/check-url.sh 127.0.0.1:8001/__heartbeat__
# ensure payments-server is ready
_scripts/check-url.sh 127.0.0.1:3031/__lbheartbeat__
# ensure content-server is ready
_scripts/check-url.sh 127.0.0.1:3030/bundle/app.bundle.js
cd packages/fxa-content-server
mozinstall /firefox.tar.bz2
# ensure email-service is ready
check 127.0.0.1:8001/__heartbeat__
# ensure payments-server is ready
check 127.0.0.1:3031/__lbheartbeat__
test_suite circle
# node 5 currently has the least work to do in the above tests

Просмотреть файл

@ -41,8 +41,7 @@ if (!userAgent.isToVersionStringSupported()) {
process.exit(1);
}
// This can't possibly be best way to librar-ify this module.
const isMain = process.argv[1] === __filename;
const isMain = require.main === module;
if (isMain) {
// ./server is our current working directory
process.chdir(path.dirname(__dirname));

1285
packages/fxa-customs-server/package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -49,6 +49,7 @@
"load-grunt-tasks": "3.5.0",
"npm-run-all": "^4.1.5",
"npmshrink": "1.0.1",
"pm2": "^4.2.3",
"prettier": "^1.18.2",
"proxyquire": "2.1.0",
"request": "2.85.0",

1752
packages/fxa-event-broker/package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -10,8 +10,10 @@
"watch": "tsc -w",
"test": "mocha -r ts-node/register src/test/**/*.spec.ts src/test/**/**/*.spec.ts",
"start-prod": "npm run build && node ./dist/bin/worker.js",
"start": "npm run build && NODE_ENV=development PUBSUB_EMULATOR_HOST=localhost:8085 FIRESTORE_EMULATOR_HOST=localhost:9090 node ./dist/bin/workerDev.js",
"start-dev-debug": "NODE_ENV=development PUBSUB_EMULATOR_HOST=localhost:8085 FIRESTORE_EMULATOR_HOST=localhost:9090 ts-node-dev --inspect=0.0.0.0:9180 ./src/bin/workerDev.ts"
"prestart": "../../_scripts/check-url.sh 127.0.0.1:9000/__heartbeat__",
"start": "pm2 start pm2.config.js",
"stop": "pm2 stop pm2.config.js",
"restart": "pm2 restart pm2.config.js"
},
"repository": {
"type": "git",
@ -66,9 +68,10 @@
"nodemon": "^2.0.2",
"npm-run-all": "^4.1.5",
"p-event": "^4.1.0",
"pm2": "^4.2.3",
"prettier": "1.19.1",
"sinon": "9.0.0",
"ts-node-dev": "^1.0.0-pre.44",
"ts-node": "^8.8.2",
"ts-sinon": "1.0.25",
"tslint": "^6.0.0",
"tslint-config-prettier": "^1.18.0",

Просмотреть файл

@ -0,0 +1,26 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
module.exports = {
apps: [
{
name: 'event-broker',
script: 'ts-node src/bin/workerDev.ts',
cwd: __dirname,
max_restarts: '1',
env: {
NODE_ENV: 'development',
NODE_OPTIONS: '--inspect=9180',
TS_NODE_TRANSPILE_ONLY: 'true',
TS_NODE_FILES: 'true',
WORKER_HOST: '0.0.0.0',
PUBSUB_EMULATOR_HOST: 'localhost:8085',
FIRESTORE_EMULATOR_HOST: 'localhost:9090',
PUBSUB_PROXY_PORT: '8090'
},
watch: ['src', 'config'],
min_uptime: '2m'
}
]
};

Просмотреть файл

@ -64,7 +64,7 @@ describe('Client Webhook Service', () => {
});
describe('using local Firestore', () => {
before(() => {
before(async () => {
const fs = new Firestore({
customHeaders: {
Authorization: 'Bearer owner'
@ -76,10 +76,14 @@ describe('Client Webhook Service', () => {
});
db = new FirestoreDatastore({ prefix: 'fxatest-' }, fs);
service = new ClientWebhookService(logger, 600, db);
await service.start();
});
after(async () => {
await service.stop();
});
it('handles immediate updates', async () => {
await service.start();
cassert.deepEqual(service.serviceData(), {});
// Manually insert into the db
const document = (db as any).db.doc('fxatest-clients/test');
@ -89,7 +93,6 @@ describe('Client Webhook Service', () => {
// Manually delete from the db
await document.delete();
cassert.deepEqual(service.serviceData(), {});
await service.stop();
});
});
});

Просмотреть файл

@ -1,5 +0,0 @@
# The express server started by server/bin/fxa-payments-server.js runs at this port:
PUBLIC_URL=http://127.0.0.1:3031
# Then it proxies to this port, where the "react-scripts start" (webpack dev server) runs:
PORT=3032
BROWSER=none

1074
packages/fxa-payments-server/package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -7,12 +7,9 @@
"lint:eslint": "eslint .",
"lint:sass": "sass-lint -v",
"audit": "npm audit --json | audit-filter --nsp-config=.nsprc --audit=-",
"start": "node server/bin/fxa-payments-server.js",
"start-dev": "npm-run-all --parallel server:proxy server:react-scripts",
"start-dev-debug": "npm-run-all --parallel server:proxy-debug server:react-scripts",
"server:proxy": "PROXY_STATIC_RESOURCES_FROM='http://127.0.0.1:3032' node server/bin/fxa-payments-server.js",
"server:proxy-debug": "PROXY_STATIC_RESOURCES_FROM='http://127.0.0.1:3032' node --inspect=0.0.0.0:9170 server/bin/fxa-payments-server.js",
"server:react-scripts": "react-scripts start",
"start": "pm2 start pm2.config.js",
"stop": "pm2 stop pm2.config.js",
"restart": "pm2 restart pm2.config.js",
"build": "react-scripts build",
"eject": "react-scripts eject",
"test": "npm-run-all test:*",
@ -83,6 +80,7 @@
"nock": "^10.0.6",
"npm-run-all": "^4.1.5",
"nyc": "^14.1.0",
"pm2": "^4.2.3",
"prettier": "^1.19.1",
"redux-devtools-extension": "^2.13.8",
"sass-lint": "^1.13.1",

Просмотреть файл

@ -0,0 +1,36 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
module.exports = {
apps: [
{
name: 'payments',
cwd: __dirname,
script: 'server/bin/fxa-payments-server.js',
max_restarts: '1',
min_uptime: '2m',
env: {
LOGGING_FORMAT: 'pretty',
NODE_ENV: 'development',
NODE_OPTIONS: '--inspect=9170',
PROXY_STATIC_RESOURCES_FROM: 'http://127.0.0.1:3032',
CONFIG_FILES: 'config/secrets.json',
PORT: '3031',
},
},
{
name: 'payments-react',
cwd: __dirname,
script: 'react-scripts start',
max_restarts: '1',
min_uptime: '2m',
env: {
NODE_ENV: 'development',
PUBLIC_URL: 'http://127.0.0.1:3031',
BROWSER: 'NONE',
PORT: '3032',
},
},
],
};

1533
packages/fxa-profile-server/package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -8,8 +8,11 @@
"lint:eslint": "eslint .",
"audit": "npm audit --json | audit-filter --nsp-config=.nsprc --audit=-",
"outdated": "npm outdated --depth 0 || exit 0",
"preinstall": "./scripts/check_gm.sh && mkdir -p var/public/",
"start": "scripts/run_dev.js",
"preinstall": "./scripts/check_gm.sh",
"prestart": "mkdirp var/public",
"start": "pm2 start pm2.config.js",
"stop": "pm2 stop pm2.config.js",
"restart": "pm2 restart pm2.config.js",
"test": "scripts/test-local.sh",
"format": "prettier '**' --write"
},
@ -54,6 +57,7 @@
"nock": "8.0.0",
"npm-run-all": "^4.1.5",
"nyc": "^14.1.1",
"pm2": "^4.2.3",
"pngparse": "2.0.1",
"prettier": "^1.18.2",
"rimraf": "2.5.3",

Просмотреть файл

@ -0,0 +1,45 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
module.exports = {
apps: [
{
name: 'profile',
script: 'bin/server.js',
cwd: __dirname,
max_restarts: '1',
env: {
NODE_ENV: 'development',
HOST: '0.0.0.0',
DB: 'mysql',
PORT: '1111',
},
min_uptime: '2m',
},
{
name: 'profile-worker',
script: 'bin/worker.js',
cwd: __dirname,
max_restarts: '1',
env: {
NODE_ENV: 'development',
HOST: '0.0.0.0',
DB: 'mysql',
},
min_uptime: '2m',
},
{
name: 'profile-static',
script: 'bin/_static.js',
cwd: __dirname,
max_restarts: '1',
env: {
NODE_ENV: 'development',
HOST: '0.0.0.0',
DB: 'mysql',
},
min_uptime: '2m',
},
],
};

Просмотреть файл

@ -4,6 +4,7 @@ set -e
rm -rf coverage
rm -rf .nyc_output
mkdir -p var/public
if [ -z "$NODE_ENV" ]; then export NODE_ENV=test; fi;

1444
packages/fxa-support-panel/package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -12,10 +12,9 @@
"audit": "npm audit --json | audit-filter --nsp-config=.nsprc --audit=-",
"test": "./node_modules/mocha/bin/mocha -r ts-node/register test/**/*.spec.ts test/**/**/*.spec.ts",
"shrink": "npmshrink && npm run postinstall",
"watch": "tsc -w",
"start-dev": "npm run build && node dist/bin/worker.js",
"start": "NODE_ENV=production node dist/bin/worker.js 2>&1",
"debug": "NODE_ENV=development nodemon --legacy-watch --watch ./dist --inspect=0.0.0.0:5858 --nolazy dist/bin/worker.js"
"start": "pm2 start pm2.config.js",
"stop": "pm2 stop pm2.config.js",
"restart": "pm2 restart pm2.config.js"
},
"private": true,
"repository": {
@ -57,6 +56,7 @@
"nodemon": "^1.19.4",
"npm-run-all": "^4.1.5",
"npmshrink": "2.0.0",
"pm2": "^4.2.3",
"prettier": "^1.19.1",
"sinon": "^7.5.0",
"ts-node": "^8.4.1",

Просмотреть файл

@ -0,0 +1,24 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
module.exports = {
apps: [
{
name: 'support',
cwd: __dirname,
script: 'ts-node bin/worker.ts',
max_restarts: '1',
min_uptime: '2m',
env: {
LOGGING_FORMAT: 'pretty',
NODE_ENV: 'development',
NODE_OPTIONS: '--inspect=9190',
TS_NODE_TRANSPILE_ONLY: 'true',
TS_NODE_FILES: 'true',
PORT: '7100',
},
watch: ['bin', 'config', 'lib'],
},
],
};