mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-08 00:22:14 +01:00
feat(debug): only build debug data when flag is true (#1167)
* only build debug info when log level is debug * introduce new flag 'gotenberg-build-debug-data' * add gotenberg-build-debug-data flag to Makefile * add new integration test for gotenberg-build-debug-data flag * update GET /debug (Enabled) test with gotenberg-build-debug-data flag * reorder GOTENBERG_BUILD_DEBUG_DATA in Makefile * reorder Build Debug Data Disabled test scenario --------- Co-authored-by: Hector Zarate <hector@Hectors-MacBook-Pro.local>
This commit is contained in:
2
Makefile
2
Makefile
@@ -18,6 +18,7 @@ build: ## Build the Gotenberg's Docker image
|
|||||||
-f $(DOCKERFILE) $(DOCKER_BUILD_CONTEXT)
|
-f $(DOCKERFILE) $(DOCKER_BUILD_CONTEXT)
|
||||||
|
|
||||||
GOTENBERG_GRACEFUL_SHUTDOWN_DURATION=30s
|
GOTENBERG_GRACEFUL_SHUTDOWN_DURATION=30s
|
||||||
|
GOTENBERG_BUILD_DEBUG_DATA=true
|
||||||
API_PORT=3000
|
API_PORT=3000
|
||||||
API_PORT_FROM_ENV=
|
API_PORT_FROM_ENV=
|
||||||
API_BIND_IP=
|
API_BIND_IP=
|
||||||
@@ -91,6 +92,7 @@ run: ## Start a Gotenberg container
|
|||||||
$(DOCKER_REGISTRY)/$(DOCKER_REPOSITORY):$(GOTENBERG_VERSION) \
|
$(DOCKER_REGISTRY)/$(DOCKER_REPOSITORY):$(GOTENBERG_VERSION) \
|
||||||
gotenberg \
|
gotenberg \
|
||||||
--gotenberg-graceful-shutdown-duration=$(GOTENBERG_GRACEFUL_SHUTDOWN_DURATION) \
|
--gotenberg-graceful-shutdown-duration=$(GOTENBERG_GRACEFUL_SHUTDOWN_DURATION) \
|
||||||
|
--gotenberg-build-debug-data=$(GOTENBERG_BUILD_DEBUG_DATA) \
|
||||||
--api-port=$(API_PORT) \
|
--api-port=$(API_PORT) \
|
||||||
--api-port-from-env=$(API_PORT_FROM_ENV) \
|
--api-port-from-env=$(API_PORT_FROM_ENV) \
|
||||||
--api-bind-ip=$(API_BIND_IP) \
|
--api-bind-ip=$(API_BIND_IP) \
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ func Run() {
|
|||||||
// Create the root FlagSet and adds the modules flags to it.
|
// Create the root FlagSet and adds the modules flags to it.
|
||||||
fs := flag.NewFlagSet("gotenberg", flag.ExitOnError)
|
fs := flag.NewFlagSet("gotenberg", flag.ExitOnError)
|
||||||
fs.Duration("gotenberg-graceful-shutdown-duration", time.Duration(30)*time.Second, "Set the graceful shutdown duration")
|
fs.Duration("gotenberg-graceful-shutdown-duration", time.Duration(30)*time.Second, "Set the graceful shutdown duration")
|
||||||
|
fs.Bool("gotenberg-build-debug-data", true, "Set if build data is needed")
|
||||||
|
|
||||||
descriptors := gotenberg.GetModuleDescriptors()
|
descriptors := gotenberg.GetModuleDescriptors()
|
||||||
var modsInfo string
|
var modsInfo string
|
||||||
@@ -137,8 +138,10 @@ func Run() {
|
|||||||
}(l.(gotenberg.SystemLogger))
|
}(l.(gotenberg.SystemLogger))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the debug data.
|
if parsedFlags.MustBool("gotenberg-build-debug-data") {
|
||||||
gotenberg.BuildDebug(ctx)
|
// Build the debug data.
|
||||||
|
gotenberg.BuildDebug(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
quit := make(chan os.Signal, 1)
|
quit := make(chan os.Signal, 1)
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,23 @@ Feature: /debug
|
|||||||
When I make a "GET" request to Gotenberg at the "/debug" endpoint
|
When I make a "GET" request to Gotenberg at the "/debug" endpoint
|
||||||
Then the response status code should be 404
|
Then the response status code should be 404
|
||||||
|
|
||||||
|
Scenario: GET /debug (Build Debug Data Disabled)
|
||||||
|
Given I have a Gotenberg container with the following environment variable(s):
|
||||||
|
| GOTENBERG_BUILD_DEBUG_DATA | false |
|
||||||
|
When I make a "GET" request to Gotenberg at the "/debug" endpoint
|
||||||
|
Then the response status code should be 200
|
||||||
|
Then the response header "Content-Type" should be "application/json"
|
||||||
|
Then the response body should match JSON:
|
||||||
|
"""
|
||||||
|
{
|
||||||
|
"version": "",
|
||||||
|
"architecture": "",
|
||||||
|
"modules": null,
|
||||||
|
"modules_additional_data": null,
|
||||||
|
"flags": null
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
Scenario: GET /debug (Enabled)
|
Scenario: GET /debug (Enabled)
|
||||||
Given I have a Gotenberg container with the following environment variable(s):
|
Given I have a Gotenberg container with the following environment variable(s):
|
||||||
| API_ENABLE_DEBUG_ROUTE | true |
|
| API_ENABLE_DEBUG_ROUTE | true |
|
||||||
@@ -86,6 +103,7 @@ Feature: /debug
|
|||||||
"chromium-proxy-server": "",
|
"chromium-proxy-server": "",
|
||||||
"chromium-restart-after": "10",
|
"chromium-restart-after": "10",
|
||||||
"chromium-start-timeout": "20s",
|
"chromium-start-timeout": "20s",
|
||||||
|
"gotenberg-build-debug-data": "true",
|
||||||
"gotenberg-graceful-shutdown-duration": "30s",
|
"gotenberg-graceful-shutdown-duration": "30s",
|
||||||
"libreoffice-auto-start": "false",
|
"libreoffice-auto-start": "false",
|
||||||
"libreoffice-disable-routes": "false",
|
"libreoffice-disable-routes": "false",
|
||||||
|
|||||||
Reference in New Issue
Block a user