feat(many): add partial stack startup scripts

Because:

- During development it could be useful to start only parts of the stack
  needed for development on specific domains.

This commit:

- Provides additional stack startup options to only start specific parts
  of the stack, by using nx projects and tags.

Closes #FXA-9771
This commit is contained in:
Reino Muhl 2024-05-30 12:40:52 -04:00
Родитель a7df9a7458
Коммит 05d7265292
Не найден ключ, соответствующий данной подписи
17 изменённых файлов: 142 добавлений и 27 удалений

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

@ -4,6 +4,7 @@ start=`date +%s`
DIR=$(dirname "$0")
COMMAND=$1
PROJECTS=$2
cd "$DIR/.."
if ! node -p 's = require("semver");v = require("./package.json").engines.node; process.exitCode = s.satisfies(process.version, v) ? 0 : 1; if(process.exitCode) {"\nPlease use node: " + v + "\n"}';
@ -12,7 +13,16 @@ then
fi
mkdir -p artifacts
npx nx run-many -t start --all --exclude=fxa-dev-launcher --verbose;
if [ -z "$PROJECTS" ]
then
# No tags provided, start the entire stack
npx nx run-many -t $COMMAND --all --exclude=fxa-dev-launcher --verbose;
else
# Start only provided projects and dependencies
# Note dependencies are automatically determined by Nx
npx nx run-many -t $COMMAND --projects=$PROJECTS --exclude=fxa-dev-launcher --verbose;
fi
end=`date +%s`
runtime=$((end-start))

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

@ -118,5 +118,5 @@
}
}
},
"tags": ["app", "payments"]
"tags": ["app", "payments", "type:sp3"]
}

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

@ -1,25 +1,114 @@
/**
* These are Nx tags used to identify which services to start up
* when executing the various partial startup scripts.
*/
const mzaProjects = 'tag:type:core,tag:type:demo';
const sp2Projects = 'tag:type:core,tag:type:demo,tag:type:sp2';
const sp3Projects = 'tag:type:core,tag:type:demo,tag:type:sp3';
module.exports = {
scripts: {
default: 'nps help',
start: {
default: `_dev/pm2/start.sh && _scripts/pm2-all.sh start && pm2 restart sync && echo "Use 'yarn stop' to stop all the servers"`,
infrastructure: `_dev/pm2/start.sh`,
services: `_scripts/pm2-all.sh start`,
default: {
script: `_dev/pm2/start.sh && _scripts/pm2-all.sh start && pm2 restart sync && echo "Use 'yarn stop' to stop all the servers"`,
description: 'Start the entire stack, i.e. all infrastructure and services.'
},
infrastructure: {
script: `_dev/pm2/start.sh`,
description: 'Start all infrastructure only.',
},
services: {
script: `_scripts/pm2-all.sh start`,
description: 'Start all Services only.'
},
firefox: './packages/fxa-dev-launcher/bin/fxa-dev-launcher.mjs &',
mza: {
script: `_dev/pm2/start.sh && _scripts/pm2-all.sh start ${mzaProjects} && pm2 restart sync && echo "Use 'yarn stop' to stop all the servers"`,
description: 'Start infrastructure and only required Mozilla Accounts services',
},
sp2: {
script: `_dev/pm2/start.sh && _scripts/pm2-all.sh start ${sp2Projects} && pm2 restart sync && echo "Use 'yarn stop' to stop all the servers"`,
description: 'Start infrastructure and only required SubPlat 2.0 services.'
},
sp3: {
script: `_dev/pm2/start.sh && _scripts/pm2-all.sh start ${sp3Projects} && pm2 restart sync && echo "Use 'yarn stop' to stop all the servers"`,
description: 'Start infrastructure and only required SubPlat 3.0 services.'
},
},
stop: {
default: 'pm2 kill',
infrastructure: `pm2 stop _dev/pm2/infrastructure.config.js`,
services: `_scripts/pm2-all.sh stop`,
default: {
script: 'pm2 kill',
description: 'Stop all infrastructure and services.',
},
infrastructure: {
script: `pm2 stop _dev/pm2/infrastructure.config.js`,
description: 'Stop all infrastructure, only.',
},
services: {
script: `_scripts/pm2-all.sh stop`,
description: 'Stop all services, only.',
},
mza: {
script: `_scripts/pm2-all.sh stop ${mzaProjects}`,
description: 'Stop required Mozilla Accounts services.',
},
sp2: {
script: `_scripts/pm2-all.sh stop ${sp2Projects}`,
description: 'Stop required SubPlat 2.0 services.',
},
sp3: {
script: `_scripts/pm2-all.sh stop ${sp3Projects}`,
description: 'Stop required SubPlat 3.0 services.',
},
},
restart: {
default: 'pm2 restart all',
infrastructure: `pm2 restart _dev/pm2/infrastructure.config.js`,
services: `_scripts/pm2-all.sh restart`,
default: {
script: 'pm2 restart all',
description: 'Restart all infrastructure and services.',
},
infrastructure: {
script: `pm2 restart _dev/pm2/infrastructure.config.js`,
description: 'Restart all infrastructure, only.',
},
services: {
script: `_scripts/pm2-all.sh restart`,
description: 'Restart all services, only.',
},
mza: {
script: `_scripts/pm2-all.sh restart ${mzaProjects}`,
description: 'Restart required Mozilla Accounts services.',
},
sp2: {
script: `_scripts/pm2-all.sh restart ${sp2Projects}`,
description: 'Restart required SubPlat 2.0 services.',
},
sp3: {
script: `_scripts/pm2-all.sh restart ${sp3Projects}`,
description: 'Restart required SubPlat 3.0 services.',
},
},
delete: {
default: 'pm2 kill',
services: '_scripts/pm2-all.sh delete',
default: {
script: 'pm2 kill',
description: 'Delete all infrastructure and services.',
},
services: {
script: '_scripts/pm2-all.sh delete',
description: 'Delete all services, only.',
},
mza: {
script: `_scripts/pm2-all.sh delete ${mzaProjects}`,
description: 'Delete required Mozilla Accounts services.',
},
sp2: {
script: `_scripts/pm2-all.sh delete ${sp2Projects}`,
description: 'Delete required SubPlat 2.0 services.',
},
sp3: {
script: `_scripts/pm2-all.sh delete ${sp3Projects}`,
description: 'Delete required SubPlat 3.0 services.',
},
},
},
};

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

@ -46,7 +46,8 @@
},
"nx": {
"tags": [
"scope:demo"
"scope:demo",
"type:demo"
]
}
}

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

@ -89,7 +89,8 @@
},
"nx": {
"tags": [
"scope:frontend"
"scope:frontend",
"type:admin"
]
}
}

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

@ -78,7 +78,8 @@
},
"nx": {
"tags": [
"scope:server"
"scope:server",
"type:admin"
]
}
}

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

@ -222,7 +222,8 @@
},
"nx": {
"tags": [
"scope:server:auth"
"scope:server:auth",
"type:core"
]
}
}

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

@ -75,7 +75,6 @@
"fxa-geodb": "workspace:*",
"fxa-mustache-loader": "0.0.2",
"fxa-pairing-channel": "1.0.2",
"fxa-payments-server": "workspace:*",
"fxa-profile-server": "workspace:*",
"fxa-react": "workspace:*",
"fxa-settings": "workspace:*",
@ -187,7 +186,8 @@
"readmeFilename": "README.md",
"nx": {
"tags": [
"scope:frontend"
"scope:frontend",
"type:core"
]
}
}

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

@ -68,7 +68,8 @@
},
"nx": {
"tags": [
"scope:server"
"scope:server",
"type:core"
]
}
}

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

@ -107,7 +107,8 @@
},
"nx": {
"tags": [
"scope:broker"
"scope:broker",
"type:broker"
]
}
}

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

@ -89,5 +89,11 @@
"prettier": "^2.3.1",
"supertest": "^7.0.0",
"typescript": "^5.4.2"
},
"nx": {
"tags": [
"scope:gql",
"type:core"
]
}
}

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

@ -197,7 +197,8 @@
},
"nx": {
"tags": [
"scope:frontend"
"scope:frontend",
"type:sp2"
]
}
}

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

@ -74,7 +74,8 @@
},
"nx": {
"tags": [
"scope:server"
"scope:server",
"type:core"
]
}
}

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

@ -112,7 +112,8 @@
},
"nx": {
"tags": [
"scope:shared:lib"
"scope:shared:lib",
"type:core"
]
}
}

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

@ -256,7 +256,8 @@
},
"nx": {
"tags": [
"scope:frontend"
"scope:frontend",
"type:core"
]
},
"babel": {

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

@ -343,7 +343,8 @@
},
"nx": {
"tags": [
"scope:shared:lib"
"scope:shared:lib",
"type:core"
]
}
}

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

@ -38013,7 +38013,6 @@ fsevents@~2.1.1:
fxa-geodb: "workspace:*"
fxa-mustache-loader: 0.0.2
fxa-pairing-channel: 1.0.2
fxa-payments-server: "workspace:*"
fxa-profile-server: "workspace:*"
fxa-react: "workspace:*"
fxa-settings: "workspace:*"