smolnar82 opened a new pull request #230: KNOX-2157 - Verifying the server's state in addition to PID check at gateway start URL: https://github.com/apache/knox/pull/230 ## What changes were proposed in this pull request? Apart from the already existing PID check, we are going to verify if the Jetty server is in `STARTED` state. We can achieve it by implementing Jetty's `LifeCylce.Listener` interface and write out the status (STARTING, STARTED, FAILURE, STOPPING, STOPPED) into `$DATA_DIR/gatewayServer.status` file. The startup script will return 0 when this file contains `STARTED`; 1 otherwise (the file is overwritten in every status change). Additionally, two new command-line options are introduced to the `start` command: * `--test-gateway-retry-attempts`: indicates the number of tries the startup script should execute before it fails. Defaults to 5. * `--test-gateway-retry-sleep`: the amount of time that the test process will wait or sleep before a retry is issued. Defaults to 2s. **Note**: currently, the `stop` command simply kills the Java process and there is no hook in the Java code to handle graceful shutdown. Because of this the `STOPPING` and `STOPPED` statuses never got written into the status file. To avoid future errors I rather added a delete command in the shell script. ## How was this patch tested? Executed a full build: ``` $ mvn clean -Dshellcheck=true -T1C verify -Prelease,package ... [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 18:24 min (Wall Clock) [INFO] Finished at: 2020-01-02T18:50:47+01:00 [INFO] Final Memory: 410M/1798M [INFO] ------------------------------------------------------------------------ ``` Tested manually: * confirmed that the new status file became created/removed when started/stopped the server * tried the `start` command with different options (`--printEnv`, `--test-gateway-retry-attempts`, `--test-gateway-retry-sleep`) * made sure (using debug messages in the shell scripts) that the status check took place (in my environment it needed 3 re-tries)
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
