Logic to shut down a singleUser appServer

Forums for specific tips, techniques and example code
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Logic to shut down a singleUser appServer

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:51 pm

by Andrew >> Fri, 6 Aug 2004 0:40:05 GMT

I'm trying to find a way to shut the appServer down (singleUser appServer) through user app logic.

I've written a non-Gui app that scans all processes, making sure that the only processes left are the appServer and self.

In the epilog, of this apps init method, I've tried 2 things:

1. run the terminate instruction to kill the app.
then force the appServer process to sign off like this appServerProcess.node.system.forceOffUser (appServerProcess.node, appServer);

2. force the appServer process to sign off like this appServerProcess.node.system.forceOffUser (appServerProcess.node, appServer);
then run the terminate instruction to kill the app.

Option 1 - I'm guessing it never gets to the forceOffUser part, as self has been terminated??
Option 2 - Doesn't result in the appServer shutting down, in fact, it leaves the appServer in a state where no further connections can be established.

jommsg:
2004/08/06 12:29:39 00900-d18 Jom: backgroundProcessException, nodeStatus= 2 error= 1205
2004/08/06 12:29:40 00900-d18 Jom: backgroundProcessException, backgroundEvent= 1
2004/08/06 12:29:40 00900-d18 Jom: backgroundProcessException, APINumber= 21 2004/08/06 12:29:40 00900-d18 Jom: backgroundProcessException, oid=[187.1]

Anyone have any ideas how to go about this?

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Logic to shut down a singleUser appServer

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:51 pm

by Mike >> Sun, 8 Aug 2004 8:04:17 GMT

Why are you wanting to shut it down from an internal app?

If you configure it to run as a service does issuing a 'netstop' achieve the desired result?

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Logic to shut down a singleUser appServer

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:51 pm

by cnwjhp1 >> Mon, 9 Aug 2004 2:47:28 GMT

We would like to do this too. At the moment, we can launch Jade databases from another controlling Jade database, do schema backups for other databases, force off all fat clients, and do WinZip backups, but haven't found a way to stop the appserver and rap. We choose not to run as services so we can glean info from the gui windows, eg to find which thin client is looping.

There must be a Windows api that would allow us to send a WM_CLOSE (like clicking the close box) to ourselves. Anyone know what it is?

Cheers,
John P

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Logic to shut down a singleUser appServer

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:51 pm

by jcampbell >> Mon, 9 Aug 2004 3:36:10 GMT

How about PostMessage( hwnd, WM_CLOSE, 0, 0 )

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Logic to shut down a singleUser appServer

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:51 pm

by cnwjhp1 >> Mon, 9 Aug 2004 4:10:59 GMT

How does one call that from Jade code?

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Logic to shut down a singleUser appServer

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:51 pm

by Andrew >> Mon, 9 Aug 2004 21:19:34 GMT

Pleased to see others have interest in this too.

I assumed there would be a little bit of native Jade code to achieve it, similar to system.forceOffUser.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Logic to shut down a singleUser appServer

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:51 pm

by jcampbell >> Mon, 9 Aug 2004 23:16:53 GMT

How about declaring an External Function something like this

postMessage(hwnd:Integer; msg:Integer; wparam:Integer; lparam:Integer):Integer is PostMessageA in user32;


and then

call postMessage(form1.hwnd, msgNum, 0, 0);


WM_CLOSE is 0x0010 for msgNum

from memory there is something in the Jade 6 doc re PostMessage

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Logic to shut down a singleUser appServer

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:51 pm

by cnwjhp1 >> Tue, 10 Aug 2004 3:34:22 GMT

Ok, when I do that with form1 set to my mdiFrame, it terminates my user app but not the appserver. Presumably I need to set form1 to the appServer or rap's desktop form so I can terminate them? How do I do this?

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Logic to shut down a singleUser appServer

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:51 pm

by jcampbell >> Tue, 10 Aug 2004 3:44:09 GMT

Not sure in Jade how you get the hwnd for the appserver or rap. You could work up thru the parent windows using GetParent function
until you get to the top level window - see http://msdn.microsoft.com/library/defau ... Parent.asp

or possibly FindWindow. There's quite a few possibilities for finding a top level window which you will see in the MSDN around the same place as the link above. I would have thought Jade would have the hwnd stored somewhere though, but possibly not directly accessable

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Logic to shut down a singleUser appServer

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:51 pm

by cnwjhp1 >> Wed, 25 Aug 2004 0:23:54 GMT

Approaching this from another angle, I am already using the freeware pv.exe (see http://www.prcview.com/) to inquire on processes, and using the -c option it will send a WM_CLOSE.

For example, this will show all Jade processes for my BlerchDB database (actually, processes whose command line includes BlerchDB):

pv jad* -l*blerchdb*

Adding -c will close the windows:

pv -c jadapp* -l*blerchdb*
pv -c jadrap* -l*blerchdb*

Note that it only works with processes that have a close box (eg does not work on nongui fat clients), and if a dialog box comes up eg "1 thin client is still connected - close anyway?", you will have to kill it (-k).

Cheers,
John P


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 4 guests

cron