Page 1 of 1 1
Topic Options
#180928 - 2007-09-28 12:15 AM How best to deploy KIX as a service.
MACE Offline
Starting to like KiXtart

Registered: 2004-09-07
Posts: 150
Loc: Manchester UK
I have developed my original 'Project Navidator' Kix Forms Folder/Project browser into a full Client/Server App for managing project folder Trees, Access Rights etc. Overall it works pretty well. The rub is the SERVER script which checks for 'Jobs' on a timer will only function if I leave the console which invoked it logged in. I have tried starting it on a schedule, I have even another scheduled kix job which runs every two minutes to check by Process ID the main script is running but NON of them seem to function unless the session is left logged in. As I am not the only one who accesses this server it is often the case that someone forgets and logs out the session then everything stops.

I have seen a small package which purports to make KIX into a service but it uses an old version and I dont have the means or knowledge to update it.

Can anyone point me in a direction which might take this to the next level as it would be a shame to have to re-code this in VB or similar. ?


Edited by MACE (2007-09-28 12:16 AM)

Top
#180930 - 2007-09-28 01:43 AM Re: How best to deploy KIX as a service. [Re: MACE]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4403
Loc: New Jersey
Just use SrvAny. I have 4 Kix-based services running in various servers:
* A service to accept files from remote workstations and consolidate the data into a central file/database
* A service to examine a directory structure for changes and initiate a replication
* a service to examine a directory structure for unauthorized or invalid changes and move/delete the offending structure
* A service that reads job files posted by a KF client. The service examines the job file, verifies that the user submitting the job is authorized, and then invokes a separate thread to process the task. This is part of a client-server based software deployment system that manages the deployment of code updates to our application and web server infrastructure.

There's no special coding requirements other than NO OUTPUT! This is easily handled by a RedirectOutput('service.log') at the beginning of the script.

I can post the instructions when I get to work tomorrow, but you can get the answers quicker by googling SrvAny - just 3 steps. Copy the SrvAny.exe to a folder; run InstSrv to define the service; Edit the registry entry to define the name of the service executable (WKix32.exe) and the parameters (script name & any args).

Oh - step 4 - start the service!

Glenn

PS - like any service, you can configure dependencies, alternate user accounts to run as, and more.
_________________________
Actually I am a Rocket Scientist! \:D

Top
#181132 - 2007-10-05 12:56 AM Re: How best to deploy KIX as a service. [Re: Glenn Barnas]
MACE Offline
Starting to like KiXtart

Registered: 2004-09-07
Posts: 150
Loc: Manchester UK
It works remarkably well.
The only think I had to re-work was a Monitor to determine if everything was behaving.
I discovered that having originally created a method to safely stop or re-start the kix script, if used the kix did as requested but the service carried on regardless putting things in a position where you had to separately stop the service then re-start it to get KIX to function as required.
The key is the content of the registry application string...
 Code:
$MS="HKEY_LOCAL_MACHINE\SYSTEM\CURRENTCONTROLSET\SERVICES\MyService"
if keyexist($MS) = 1
 $=WRITEVALUE ($MS+"\Parameters", "Application", "wkix32.exe C:\MyKixProject\MyService.kx /i", "REG_SZ")
 run 'regedit.exe'
 sleep 2
 $=messagebox($MS+"\Parameters - Application","Browse to:")
Endif


Thanks

Top
#181147 - 2007-10-05 04:54 AM Re: How best to deploy KIX as a service. [Re: MACE]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4403
Loc: New Jersey
Mace,

Glad it worked!

If you can stop the Kix script independent of the Service Control, why not add a line to the kix script to stop the service? Kind of like this concept:
 Code:
init stuff...

While $Service = 1

 do the service stuff..

 If $Should_We_Shutdown ; this is your independent shutdown detection logic
  $Service = 0
 EndIf
Loop

code to tidy up...

Run 'net stop my_kix_service'
Exit 0

The "Run net stop" just before the exit will insure the service is in a stopped state if the service script terminates itself.

Also, in the registry, I use
Parameter:Application = WKix32.exe
Parameter:AppParameter=path\name_of_script.kix args...

This lets you separate the service arguments (script and args) from the service application (Kix.exe)

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
Page 1 of 1 1


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 641 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.13 seconds in which 0.069 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org