cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to identify if hybris server is completely started?

former_member625518
Discoverer
3,566

There is a requirement to identify whether the hybris server is completely started and then only enable the cronjobs by setting cronjob.timertask.loadonstartup=true (default is false). I tried to use the HybrisContextLoaderListener for this. I used the contextInitialized() method and put my logic there. However, it gets called while the server is starting up, and not when it is fully up.

Is there any way to identify this? Will reading the console log and checking the server startup message help?

Please suggest how this can be achieved.

Accepted Solutions (0)

Answers (3)

Answers (3)

VinayKumarS
Active Contributor

In any version of the SAP Hybris server started you will notice below logs.

If you dont find any option from the application. Then reading the logs is the best option.

Aug 10, 2012:10:26 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-9001"]
Aug 10, 2019 12:10:26 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["https-jsse-nio-9002"]
Aug 10, 2019 12:10:26 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8009"]
Aug 10, 2019 12:10:26 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8010"]
Aug 10, 2019 12:10:26 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 267499 ms
former_member625518
Discoverer
0 Likes

Yes, I was thinking about the same. But then the next question is should I read the log inside the HybrisContextLoaderListener itself? I guess if I do that initially it won't be a match. I can use a while loop and keep checking the occurrence of the server startup message. But not sure whether putting this check on a loop will impact the overall listener's behaviour. Any insights?

0 Likes

Hi. You can use init method of some servlet for such purposes.
I had mainly the same task. Implement Spring listener that will be triggered on ContextRefreshedEvent and it will try to send request to your servlet. The last attempt will be successful and you will be able to execute code inside your init() method only once.
And if you don't mind, please, provide your solution if it's possible

arvind-kumar_avinash
Active Contributor
0 Likes

If you are using Linux, you can use the following command:

ps -ef | grep tomcat 

If the result contains the whole path of tomcat, it means that it has started.

Alternatively, you can use the following command and if it returns something like, Connecting to localhost|::1|:9002... connected., it means that the server has been started.

wget http://localhost:9002