You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@knox.apache.org by GitBox <gi...@apache.org> on 2020/01/03 09:46:50 UTC

[GitHub] [knox] smolnar82 commented on issue #230: KNOX-2157 - Verifying the server's state in addition to PID check at gateway start

smolnar82 commented on issue #230: KNOX-2157 - Verifying the server's state in addition to PID check at gateway start
URL: https://github.com/apache/knox/pull/230#issuecomment-570520825
 
 
   The main difference between our tests and the way how we start it from the startup script is:
   * within the tests we directly call `GatewayServer.startServer` (usually in methods annotated with `@BeforeClass`) and wait until it returns
   * whereas in the script - where the application is configured to run in the background by default - creates a Java process with `nohup` which invokes `GatewayServer.main()` with the given argument and let the process live its own life in the background. Right after the Java call the script continues to check if the PID exists. Usually, it takes some time for the server to start up but the script indicates it's up&running because the PID is there.
   
   It's not _easy_ to add hook in a shell script to check the 2nd case:
   1. either the server persists its state somewhere which the script can read (this is what I implemented here)
   2. or the script tries to ping the server somehow
   2.1. The REST API would be ideal, but this would require at least one servlet which does not require authentication.
   2.2. Or one might try to check if the port is open. For instance:
   ```
   $ nc -z localhost 8443
   
   $ echo $?
   1
   
   $ nc -z localhost 8443
   
   $ echo $?
   1
   
   $ nc -z localhost 8443
   Connection to localhost port 8443 [tcp/pcsync-https] succeeded!
   
   $ echo $?
   0
   ```

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services