Using SHC to initiate a daily server CRON

The forum to discuss the Headless version of Servoy. Web, Java and Servlet development questions can all be posted here.

Using SHC to initiate a daily server CRON

Postby Morley » Tue May 03, 2005 11:38 pm

I need to initiate a CRON which in turn triggers a daily server utility method. This routine needs to run daily whether or not any users are active, independent of users.

Several weeks ago Jan Aleman recommended SHC as the way to go.

Morley wrote:I currently have a startup script running just fine in my isolated development environment. However I believe some routines should run only when the server is launched, such as a midnight Cron scheduler which does a global reset on all incomplete task records, rolls over tasks scheduled for completion yesterday and reschedules them for today.

Jan Aleman wrote:You can use deeplinking to a method for this by executing a URL in your cron. The url can launch a (headless) client and perform the script you indicate through the URL (2.2 and later, see 2.2 release notes for details on deeplinking to a method)


I've not been able to locate the 2.2 release notes Jan references (awaiting 2.2's final release?). The above is the only place "deeplinking" is used in Servoy Talk, haven't seen it anywhere else.

I'm just getting my toes wet with SHC. For the time being this is all I want to do with SHC -- establish a CRON which will run a method daily shortly after midnight independent of any end user. Anyone have pointers on this?
Morley Chalmers
7Office Inc.
User avatar
Morley
 
Posts: 891
Joined: Fri Apr 25, 2003 4:54 pm
Location: Toronto, Canada

Postby Jan Aleman » Wed May 04, 2005 9:17 am

In the release notes of the first beta of 2.2 at
http://forum.servoy.com/viewtopic.php?t=3546

you will find this:
[enh]-http://<servoy_server_ip>/servoy-client/servoy_client.jnlp?solution=crm&method=showOrder&argument=10444&rnd=12302 will only open a client when no one is running that solution, otherwise the running client will execute this method (will only work in one local network!)

Note that that launches a normal client, so you must run it on a server with GUI.

You can also go headless in which case you will create:

1. the method inside servoy that does the work
2. a jsp page in Servoy/server/webapps/root that contains something like this:

Code: Select all
<%@ page import = "java.util.*" %>
<%@ page import = "com.servoy.j2db.server.headlessclient.*" %>
<%@ page import = "com.servoy.j2db.dataprocessing.IDataSet" %>
<%@ page errorPage="errorpage.jsp" %>
<%
   ISessionBean servoy_hc = (ISessionBean)session.getAttribute("servoy");
   if (servoy_hc == null)
   {
      servoy_hc = HeadlessClientFactory.createSessionBean(request,"SOLUTION");
      session.setAttribute("servoy",servoy_hc);
   }
   boolean ok = servoy_hc.setMainForm("MAINFORM");
String result = (String)servoy_hc.executeMethod(null,"DOSTUFF",null);
%>


SOLUTION = the solution you want to connect to
MAINFORM = the form you want to use as main form, prob the one that maintance method is attached to
DOSTUFF = the name of the method you want to execute[/code]
Jan Aleman
Servoy
Jan Aleman
 
Posts: 2083
Joined: Wed Apr 23, 2003 9:49 pm
Location: Planet Earth

Postby Morley » Wed May 04, 2005 8:51 pm

Thanks, appreciated.

Supplemental. Does the computer triggering the headless client need to be kept running, i.e. that instance of a client use kept running in order for the Cron to keep running?

If so, this becomes a vulnerability. I need this utility function to run daily regardless.

Kind regards,
Morley Chalmers
7Office Inc.
User avatar
Morley
 
Posts: 891
Joined: Fri Apr 25, 2003 4:54 pm
Location: Toronto, Canada


Return to Servoy Headless Client

Who is online

Users browsing this forum: No registered users and 5 guests