Victor Valencia
Victor Valencia

Reputation: 1

how can I check if portlet is deployed or active?

In my job have a Portal (Liferay but customized) with our own portlets, they works perfectly but the deployment of all them take too long(30-40 minutes), one of my goals is to know when every single portlet is up, tipically the user have to go the portlet view and check if the portlet is available, but this is considered unpractically.

I'm making a bash script, basically it executes http requests through cURL to the views of every portlet, but it is not working in the way I wanted, because even when the portlet is not deployed, the resource is marked as available, do you have a suggestion or something for this issue?, I'll attach a piece of my code below

#!/bin/bash

portlet='web/view/your_first_portlet web/view/your_second_portlet';
for i in $portlet;do
   if [ -z "$(curl -v --silent http://portal/$i 2>&1 | grep "The requested resource was not found.")" ]
   then
      echo "$i is ready"
    else
      echo "$i is NOT ready"
    fi
done

When the cURL command runs , it search for an ocurrence of the string "The requested resource was not found." because I discovered that when the resource is not available, in catalina ouput(tomcat) throws a null, but with http request shows the message inside the code returned, but even with it the portlet is not deployed and the script says otherwise.

Upvotes: 0

Views: 423

Answers (1)

Olaf Kock
Olaf Kock

Reputation: 48057

If the deployment of a single webapp (with a portlet) takes 30-40 minutes, I'd start working on that aspect, rather than on a workaround for waiting more patiently.

That being said, instead of accessing a full page that happens to have the portlet deployed, how about you implement a serveResource method in your portlets, obtain the resourceURL for each portlet you're interested in and just access this URL. A resource request will only be handled if the portlet is fully deployed. This way just evaluating the HTTP error code should do the trick.

But first and foremost: Find out what takes so long and shorten it.

Upvotes: 2

Related Questions