//Get the application type
var appType = application.getApplicationType();
//type 1 = SERVER
//type 2 = CLIENT
//type 3 = DEVELOPER
//type 4 = HEADLESS_CLIENT
//type 5 = WEB_CLIENT
//type 6 = RUNTIME
//Close the current open solution and optionally open a new one
if (appType == 4) {
application.closeSolution();
}
when running as a batch process?
When I try “start” in the servoy-admin page the headless client does not seem to close.
My objective is to start the solution as a batch process upon startup of the application server, run, then close itself.
Marcel,
While a timeout would work eventually. I would want a short timeout but prefer that the application.closeSolution() actually work immediately.
Is this expected behaviour in a headless client or a defect? If “expected” then I will raise a support request to change it if no impact anywhere else of course.
All:
The second part of my question is how does one start a batch process (headless client) when the application server starts up? IS this outside the scope of Servoy programming model and has to be done by a batch file?
Thomas Parry:
Marcel,
While a timeout would work eventually. I would want a short timeout but prefer that the application.closeSolution() actually work immediately.
Is this expected behaviour in a headless client or a defect? If “expected” then I will raise a support request to change it if no impact anywhere else of course.
You can simply configure the headless client to close the session when it’s done, have a look at this syntax (especially the last line):
Thomas Parry:
The second part of my question is how does one start a batch process (headless client) when the application server starts up? IS this outside the scope of Servoy programming model and has to be done by a batch file?
Take a look at the admin pages, all you need to setup batch processors is there.
Nicola,
thanks for the sample code - which I do not understand yet because it seems to be JSP?
I was assuming that I could write a global method to the the “work” and then assign the solution onOpen method to this method. I tested this and it seems to work.
My last line was as you can see in my code to close the solution. I had assumed that the Servoy application.closeSolution would function as advertised in a headless client since the help documents make no distinction.
IN my version 3.5.7 the admin pages only have “Start”/“Close” and “Remove” buttons. There is no attribute or field to indicate that I want it executed at application server start up time. Or does it start automatically?
Sorry, I was too quick to read your post, forget all I said, that is related to an headless client called through jsp.
What you simply need is to create a solution, setup a startup method to execute all your stuff and at the end call “application.exit()”.
To setup the batch processor to automatically start at servoy server startup go to the Admin Pages, click on the batch Processor link on the left, select your solution, enter username/password if login is needed to access that solution and optionally a string to pass as argument to the startup method, click the add button and it will be added to the list of batch processors. Everytime the servoy server is started all the batch processor in the list will be started as well.
Well I should have read the doc a little closer as they say. I had assumed the .close was the correct method but now I see it should be exit. Thanks for pointing out that I should read twice and talk once!
The small little solution with the global method now runs at server startup, then exits nicely.
Tom