==What is it==
This service will watch (query) MapGuide and restart it if anything is wrong with it following certain parameters. I have made this in my spare time and decided to share it.

*.NET 2.0
*Must be installed on the MapGuide server machine, the web extensions can be somewhere else.

The following files are in the zip:


1-Create a folder in your C root, name it “mgstatus” and extract all files to it
2-Change settings in config.ini
3-run install-service.bat
4-go to services.msc and start the service


1-Stop the service
2-run uninstall-service.bat (close services.msc if it is open)
3-delete c:\mgstatus

For now the config.ini path is hardcoded and MGS.exe will look for it in: C:\mgstatus\ , if you really need to you can put all the other files else where, but the config file must be in this path. This will be soon changed.

config.ini – contains configuration
install-service.bat -- installs the service
uninstall-service.bat – uninstalls the service
MGS.exe – the MapGuide Status executable
Pskill.reg – If you will use pskill (explained later) you will have to run this before activating it.

The config.ini is only read on startup; if you make any changes to it you must stop and start the service.

IMPORTANT: Settings in this file should not be moved around and unused settings should be left as is, MGS expects this file to be in a certain format (certain setting is in certain line). Do not add extra carriage returns or unneeded spaces.
*File for logging:
This is where MGS will write its log file, it contains info on his queries and/or errors, double backslashes required.
*Time to check MapGuide (in seconds): 1800 = 30 mins, 600 = 10 mins, 60 = 1 min :
This setting determines at what interval MGS will check if MapGuide is ok.
*How much time to wait when MapGuide is restarted before checking it again (seconds):
Depending on the speed of your setup, you can give MapGuide more time.
*Test url, this url should work as if in IE:
This is the most important setting, as this is how MGS will know if MapGuide is responding correctly. It will be explained below.
*How many seconds to wait for an answer from MapGuide before timing out:
This setting determines how much time MGS will wait for MapGuide before considering something is wrong with it.
*Do we check for size?:
This setting is a double edge sword setting, upon the first request it will remember the size of MapGuide’s response, if the next time MGS checks MapGuide the response is not the same size it will consider something is wrong. This is to help detect when one provider crashes, but the service is still up, the size of the answer will not be the same. On the other side, if your data somehow changes or you update it, you have to remember to restart MGS or else it will detect this as a change. Also the only way to reset the first size remembered by MGS is to restart it.
*Time for MapGuide daily restart (24H) (-1 for never),3 = 3AM, 12 = Noon, 23 = 11PM:
At said time, MGS will restart MapGuide, for this setting to work properly the check for MapGuide interval setting must be at one hour or less.
*Do we use pskill, else killing MapGuide will be done via .NET
This setting will be explained later.
*Pskill's path , this is used if the option before is set to true.
The path where pskill.exe is, double backslashes required. If you are not using pskill leave this setting as is.
*MapGuide service name as in services.msc, properties, display name
This is for MGS to know what service it is watching.
*MapGuide's process name
OpenSource is mgserver.exe , Enterprise is mgserver20XX.exe

==Extra info==
*Test url, this url should work as if in IE - > This setting is constructed like this:
http://localhost/mapguide/mapagent/mapagent.fcgi -> the url to the fcgi, if you have Enterprise, this will be different.
-MAPNAME=citymap -> citymap is the name of your map
-MAPDEFINITION=Library%3A%2F%2Fcitymap.MapDefinition -> this is the MapGuide path to your mapDefinition, it’s a url version of Library://citymap.MapDefinition
-SETVIEWCENTERX=307545&SETVIEWCENTERY=5036491 -> these are the coordinates the query will take place; these must be valid and change depending on your map and syscoords.
-USERNAME=Anonymous&PASSWORD= -> this is the default if Anonymous is allowed and he has no password, you have to make sure to get no prompt because MGS does not support it.

A complete example url will look like this : (all on one line in the config)


Make sure there is no space after the last =

NOTE : For MGS to work correctly, use must be able to open this url in your browser as it is in the config file and get a valid image.

*Do we use pskill, else killing MapGuide will be done via .NET ->
The reason of this setting was that under certain circumstances (windows server 2000), using .Net’s Process.Kill did not actually kill the process. As a work around I added the ability for MGS to use pskill to kill MapGuide and this worked. Pskill is free and is available at , the reg file must be run before turning this option on, or else MGS will not work when calling it.

The program is free, the source code is attached, it is a simple .Net application.
If you would like me to add something to it, check the following thread :

Last modified 9 years ago Last modified on Jul 13, 2009 2:07:19 PM

Attachments (2)

Download all attachments as: .zip