Lighthouse job orchestrator
Lightkeeper is a simple lighthouse job orchestrator made with nodejs.
npm install -g lighthouse
npm install -g lighthouse-orchestrator
# generate default configuration
lightkeeper --init-config
# run it
lightkeeper
Available arguments :
—config-dir :
Directory containing your config files, default is current directory.
See below for configuration details.
—data-dir :
Directory for output storage, defaults to ./data.
See below for output details.
—init-config :
Writes default configuration to “config-dir” path so you can adapt them to your needs.
—init-profiles :
Writes default lighthouse profiles to “config-dir” path so you can adapt them to your needs.
git clone git@github.com:GGracieux/lighthouse-orchestrator.git
build dockerfile
docker build -t lightkeeper .
Create a docker-compose.yml specifying config-dir and data-dir folders (see below for configuration and output details). For example :
version: '3.2'
services:
lightkeeper:
image: lightkeeper
volumes:
- /tmp/conf:/lightkeeper/conf:rw
- /tmp/data:/lightkeeper/data:rw
ports:
- 8086:80
docker-compose up
All configuration files must be located under the config-dir passed as command argument.
A set of example configurations are available under /examples :
This file defines the jobs to run with lighthouse. Each job must specify the following properties :
Additional properties can be added, they can be writent to result log according to result log configuration.
If your config-dir does not have a jobs.json file, lightkeeper uses it’s default (see /default-conf/jobs.json)
For example the following jobs.json file runs :
{
"url":"https://www.example.com",
"profiles":[ "mobile"],
"cron": "1 */30 * * * *"
},
{
"url":"https://www.google.com",
"profiles":[ "mobile", "desktop"],
"cron": "1 1 */1 * * *"
}
This file defines the general execution parameters of lighkeeper.
Lightkeeper loads it’s default configuration (see /default-conf/lightkeeper.json) and then overloads it with your custom lightkeeper.json file located under config-dir folder.
The following lightkeeper.json file is the default configuration :
{
"reports":{
"formats": ["html"],
"retentionDays": 7
},
"logs":{
"lightkeeper":{
"retentionDays": 7
},
"results":{
"fields":{
"run":[
"id",
"url",
"profile",
"qdate"
],
"lighthouse":[
"categories.performance.score",
"audits.time-to-first-byte.numericValue",
"audits.speed-index.numericValue",
"audits.total-byte-weight.numericValue",
"audits.dom-size.numericValue"
]
},
"fieldSeparator": ";",
"retentionDays": 7
},
"errors": {
"retentionDays": 7
}
},
"webserver":{
"enabled": false,
"port": 8086,
"content": {
"folders": ["reports", "logs", "queue"],
"searchable": true
},
"authentication": {
"enabled": false,
"users": {
"alice": "123456",
"bob": "abcdef"
}
},
"https":{
"enabled": false,
"certificate": {
"key":"your-certificate.key",
"crt":"your-certificate.crt"
}
}
},
"jobsRunner": {
"maxParallelJobs": 1
}
}
The profile.xxxxx.json files are lighthouse configuration files. The xxxxx filename part defines the profile name which you can use in jobs.json.
You can add as many profile as you want based on lighthouse configuration format
Lightkeeper comes with two default profiles, mobile and desktop, they are identical to lr-desktop-config.js and lr-mobile-config.js
You can add new profiles by writing profile.xxxx.json files under config-dir.
You can overwrite default mobile and desktop files by writing profile.mobile.json and profile.desktop.json under config-dir.
Every data produced by lightkeeper is stored under the data-dir passed as command argument.
According to lightkeeper.json, the data-dir folder can be exposed through http.
This is the application log, it monitors job activity.
Log example
2019-10-29T21:18:01.244Z|info|Worker01, no test in queue, waiting ..
2019-10-29T21:19:01.244Z|info|Worker01, no test in queue, waiting ...
2019-10-29T21:20:01.010Z|info|QManager, Job 1572384001010-705 : Adding (mobile) https://www.google.com
2019-10-29T21:20:01.010Z|info|QManager, Job 1572384001010-895 : Adding (desktop) https://www.google.com
2019-10-29T21:20:23.251Z|info|Worker01, Job 1572384001010-705 : Launching : (mobile) https://www.google.com
2019-10-29T21:20:32.985Z|info|Worker01, Job 1572384001010-705 : Processing (mobile) https://www.google.com
2019-10-29T21:20:32.988Z|info|Worker01, Job 1572384001010-705 : Ending (mobile) https://www.google.com
2019-10-29T21:20:32.988Z|info|Worker01, Job 1572384001010-895 : Launching : (desktop) https://www.google.com
2019-10-29T21:20:42.853Z|info|Worker01, Job 1572384001010-895 : Processing (desktop) https://www.google.com
2019-10-29T21:20:42.855Z|info|Worker01, Job 1572384001010-895 : Ending (desktop) https://www.google.com
2019-10-29T21:20:42.856Z|info|Worker01, no test in queue, waiting ...
2019-10-29T21:21:42.856Z|info|Worker01, no test in queue, waiting ...
This is the results log, it logs results according to lightkeeper.json configuration file
Log example
1572384001010-705;https://www.google.com;mobile;2019-10-29T21:20:01.010Z;0.97;116.51500000000001;1536.5892489842574;289790;411
1572384001010-895;https://www.google.com;desktop;2019-10-29T21:20:01.010Z;1;117.94599999999997;499.14791362486005;406031;237
This folder contains details on errors, temporary files, etc …
This folder contains a directory stucture as follow : /reports/YYYY/MM/DD/report-files.ext
directory listing example
ls -l reports/2019/10/29/
1572384001010-705-mobile-https:www.google.com.csv
1572384001010-705-mobile-https:www.google.com.html
1572384001010-705-mobile-https:www.google.com.json
1572384001010-895-desktop-https:www.google.com.csv
1572384001010-895-desktop-https:www.google.com.html
1572384001010-895-desktop-https:www.google.com.json
This folder contains the job queue