| 1 | ==What is it== |
| 2 | 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.[[BR]] |
| 3 | |
| 4 | ==Requirements==[[BR]] |
| 5 | *.NET 2.0[[BR]] |
| 6 | *Must be installed on the !MapGuide server machine, the web extensions can be somewhere else.[[BR]] |
| 7 | |
| 8 | The following files are in the zip:[[BR]] |
| 9 | config.ini[[BR]] |
| 10 | pskill.reg[[BR]] |
| 11 | MGS.exe[[BR]] |
| 12 | install-service.bat[[BR]] |
| 13 | uninstall-service.bat[[BR]] |
| 14 | |
| 15 | ==Installing==[[BR]] |
| 16 | [[BR]] |
| 17 | 1-Create a folder in your C root, name it “mgstatus” and extract all files to it[[BR]] |
| 18 | 2-Change settings in config.ini[[BR]] |
| 19 | 3-run install-service.bat[[BR]] |
| 20 | 4-go to services.msc and start the service[[BR]] |
| 21 | [[BR]] |
| 22 | ==Uninstalling==[[BR]] |
| 23 | [[BR]] |
| 24 | 1-Stop the service[[BR]] |
| 25 | 2-run uninstall-service.bat (close services.msc if it is open)[[BR]] |
| 26 | 3-delete c:\mgstatus[[BR]] |
| 27 | [[BR]] |
| 28 | ==Information==[[BR]] |
| 29 | 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.[[BR]] |
| 30 | [[BR]] |
| 31 | config.ini – contains configuration[[BR]] |
| 32 | install-service.bat -- installs the service[[BR]] |
| 33 | uninstall-service.bat – uninstalls the service[[BR]] |
| 34 | MGS.exe – the !MapGuide Status executable[[BR]] |
| 35 | Pskill.reg – If you will use pskill (explained later) you will have to run this before activating it.[[BR]] |
| 36 | [[BR]] |
| 37 | The config.ini is only read on startup; if you make any changes to it you must stop and start the service.[[BR]] |
| 38 | [[BR]] |
| 39 | [[BR]]==Config==[[BR]] |
| 40 | 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.[[BR]] |
| 41 | *File for logging:[[BR]] |
| 42 | This is where MGS will write its log file, it contains info on his queries and/or errors, double backslashes required.[[BR]] |
| 43 | *Time to check !MapGuide (in seconds): 1800 = 30 mins, 600 = 10 mins, 60 = 1 min :[[BR]] |
| 44 | This setting determines at what interval MGS will check if !MapGuide is ok.[[BR]] |
| 45 | *How much time to wait when !MapGuide is restarted before checking it again (seconds):[[BR]] |
| 46 | Depending on the speed of your setup, you can give !MapGuide more time.[[BR]] |
| 47 | *Test url, this url should work as if in IE:[[BR]] |
| 48 | This is the most important setting, as this is how MGS will know if !MapGuide is responding correctly. It will be explained below.[[BR]] |
| 49 | *How many seconds to wait for an answer from !MapGuide before timing out:[[BR]] |
| 50 | This setting determines how much time MGS will wait for !MapGuide before considering something is wrong with it.[[BR]] |
| 51 | *Do we check for size?:[[BR]] |
| 52 | 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.[[BR]] |
| 53 | *Time for !MapGuide daily restart (24H) (-1 for never),3 = 3AM, 12 = Noon, 23 = 11PM:[[BR]] |
| 54 | 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.[[BR]] |
| 55 | *Do we use pskill, else killing !MapGuide will be done via .NET[[BR]] |
| 56 | This setting will be explained later.[[BR]] |
| 57 | *Pskill's path , this is used if the option before is set to true.[[BR]] |
| 58 | The path where pskill.exe is, double backslashes required.[[BR]] |
| 59 | *!MapGuide service name as in services.msc, properties, display name[[BR]] |
| 60 | This is for MGS to know what service it is watching.[[BR]] |
| 61 | *!MapGuide's process name[[BR]] |
| 62 | !OpenSource is mgserver.exe , Enterprise is mgserver20XX.exe[[BR]] |
| 63 | [[BR]] |
| 64 | ==Extra info==[[BR]] |
| 65 | *Test url, this url should work as if in IE - > This setting is constructed like this:[[BR]] |
| 66 | http://localhost/!MapGuide/mapagent/mapagent.fcgi -> the url to the fcgi, if you have Enterprise, this will be different.[[BR]] |
| 67 | -MAPNAME=citymap -> citymap is the name of your map[[BR]] |
| 68 | -MAPDEFINITION=Library%3A%2F%2Fcitymap.MapDefinition -> this is the !MapGuide path to your mapDefinition, it’s a url version of Library://citymap.MapDefinition [[BR]] |
| 69 | -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.[[BR]] |
| 70 | -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.[[BR]] |
| 71 | |
| 72 | A complete example url will look like this : (all on one line in the config)[[BR]] |
| 73 | {{{ |
| 74 | [[BR]] |
| 75 | http://localhost/mapguide/mapagent/mapagent.fcgi?OPERATION=GETMAPIMAGE&VERSION=1.0.0&MAPNAME=citymap&LOCALE=en&MAPDEFINITION=Library%3A%2F%2Fcitymap.MapDefinition&FORMAT=JPG&SETVIEWCENTERX=307545&SETVIEWCENTERY=5036491&SETVIEWSCALE=1000&SETDISPLAYDPI=16&SETDISPLAYWIDTH=300&SETDISPLAYHEIGHT=200&USERNAME=Anonymous&PASSWORD= |
| 76 | [[BR]] |
| 77 | }}} |
| 78 | |
| 79 | Make sure there is no space after the last =[[BR]] |
| 80 | [[BR]] |
| 81 | 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.[[BR]] |
| 82 | [[BR]][[BR]] |
| 83 | *Do we use pskill, else killing !MapGuide will be done via .NET ->[[BR]] |
| 84 | 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 http://technet.microsoft.com/en-ca/sysinternals/bb896683.aspx , the reg file must be run before turning this option on, or else MGS will not work when calling it.[[BR]] |
| 85 | |
| 86 | ==About==[[BR]] |
| 87 | The program is free, I will probably add the source code after some changes, but it is a simple .Net application and it is not obfuscated, you can easily decompile it and look at the code if you are in a hurry.[[BR]] |