Monday, August 6, 2007

Installer Release

Yay! I got it to work! Here were the major issues holding my progress up:

  • Timing of commands - When you execute commands in a script as opposed to on the command line, the behavior is completely different. The operating system essentially goes down the list of commands and spawns each one off. If a command takes longer to execute than you may expect, and your next command depends on the previous one: disaster. Normally you would fight this using the built-in 'start /wait ' mechanism, but the nature of how Bitrock executes post-install scripts really hinders this because sometimes the installer will just hang if you use the /wait switch. Couple this with the fact that Windows XP doesn't have a 'wait' or a 'sleep' command, and you've got yourself a headache. To fix this issue, I started the MySQL server first, then I did the silent install of Java to kill some time, and THEN I reset the root password for MySQL. That handled the timing, and fixed the SQL script issue.
  • Behavior of 'service.bat' - This script is provided with Tomcat for a simple way to install Tomcat as a Windows Service. The problem is, if you call it from within a script, nothing else in your script will get executed after 'service.bat' finishes. No combination of switches can save you here, the reason being is that while you may say '/wait', 'startup.bat' executes a number of other commands that don't use that method of execution. So, instead of calling 'startup.bat' as part of the post-install script, I call it from within Bitrock prior to the execution of the post-install script, and then I simply start the Tomcat service in the script.
  • Build times - As I've stated before, this really killed me. Any change I wanted to implement and test would take a total of 15 minutes before I would know if it worked or not. That's a lot of time lost, especially considering the hit-or-miss nature of the testing environment due to the issues I listed above. Something will behave one way locally in the script, but how it behaves in Bitrock is entirely different.
Well, those are a summary of the issues. I bottled them up nicely and it only seems like 3 things, but there are a number of painful individual things within each of them.

Installation Tips
  • This installer assumes you have none of the dependencies. Please make sure this is the case. No JRE, No Tomcat, and No MySQL.
  • At the MySQL Information screen, the dialog is a bit misleading. These will be cleaned up, but for now just know that the username MUST be 'root'. The password can be whatever you want it to be.
  • At the Tomcat Information screen, the dialog is on task, but to be safe and sure that you are experiencing the same installer that I did, leave the username as 'admin'. It shouldn't matter, but I can't recall how I setup the tomcat-users.xml file just now, so I make no guarantees. (Although, this would be good info for your bug report feedback).
  • When the installer tells you that it's executing the final installation script, be patient. It will take a relatively long time, but trust me, it does finish. You may see an error box pop-up that says something about "Error sending parameters to program..." and it will display the URL for the OpenMRS system. I'm not sure why this comes up, but just hit "OK" A browser should pop-up and display the OpenMRS system. You may have to refresh it, but probably not. Once the script finishes, you'll have the option of displaying a Readme, and then you'll be done.
  • The installer currently places Tomcat and MySQL inside of the installation directory. This is not permanent, but I have some issues to work out involving the dependency checking and setting path/environment variables accordingly, so that's why I'm not placing them in their proper locations just yet.
Strange Behavior
  • As seems to be par for the course, sometimes the script doesn't execute properly for seemingly no reason at all. If this is the case, you'll probably get an error saying the script didn't execute successfully, and you'll see an error page for Tomcat. For example, I just ran a new build of the installer that had no effect on the SQL scripts, but for some reason all of the SQL scripts failed saying that they couldn't find the "openmrs" database. I ran the SQL scripts manually, and guess what? No errors, I restarted Tomcat, and the system was fine. It honestly and truly makes no sense. There must be some strange timing issues going on, and I just don't have the time to waste fixing them right now. Let me know if you have this issue and I can get you up and running very easily. All you need to do is finish the installer (not cancel it), and then run the SQL scripts located in ${installdir}/model (where ${installdir} is the location you chose to install OpenMRS). You'll have to follow the instructions from the website on how to execute those scripts (if this becomes a widespread issue I'll type up an updated tutorial), but once you do, simply restart Tomcat and you're good to go. I'm not going to ignore this issue, I just need to focus on other elements of the installer currently; this isn't something that fails every time. I think the issue for me is that my Vmware image runs very slowly. Given that, if the createdb script doesn't finish in time, then the rest of the scripts will fail. I'm almost entirely certain that's what happened in my last run. I'd have to do some string modification to alter the SQL script commands to be executed using the 'start /wait' mechanism, but once that was in place it would solve the issue.
Update
I decided to re-run the first working version that I had tonight. This is a version that worked with no problems at all the first time I ran it. Guess what happened when I ran it this time? It never created the database. This version never had that issue, only the newer one did. This just goes to show you the ridiculousness I've been dealing with. It seems that it randomly just doesn't create the openmrs database. In fact, in other occasions outside of Bitrock, I've gotten strange SQL errors saying that certain "concepts" didn't exist. I think there is some sort of bug behind the scenes with MySQL or these scripts. I'm not losing my mind, I know for a FACT that the version I've uploaded worked on a bare system. I reset my VM, and surprise! It didn't work. Regardless, with the version I put up (the first working version), if you get a Tomcat error saying it can't find OpenMRS, just run the SQL scripts manually and restart Tomcat.

By the way, I decided to not upload the "newer" build. The one thing the newer build fixed was it made Tomcat's service "auto" start. So, for this build you'll have to change that start type in "Settings, Control Panel, Admin Tools, Services, Right-Click on Apache Tomcat, Properties, Startup, Auto".


Please let me know of any issues/bugs/suggestions you may have. Thanks!

resources.openmrs.org/OpenMRS-1.0-installer.exe

2 comments:

Ben Wolfe said...

Awesome, this is great Zach!

I was able to install over the top of my development environment -- just choosing different ports for mysql/tomcat and a different db name. I encourage everyone to attempt the install.


My suggestions:

Change "Please wait while Setup installs OpenMRS on your computer" to "Please wait while OpenMRS is installed on your computer". Saying "Setup" sounds odd to me.

You redirect to http://localhost:8080/openmrs even though I specified a different port for tomcat.

Another option you can give to the user is "webapp name". Currently most people us "openmrs", but a setting in the openmrs runtime properties can change it to anything. (Future enhancement)

Add a link to openmrs.org in OpenMRS's start menu.

The "post install output" screen is a little confusing. Can you show this only if there is an error? Can you put some text up there saying _why_ its being shown to the user?

The final readme is a little bland. Can it take html links? If not, I suggest you put some "quick startup" instructions in there so users know where to start messing around and where to look for help (openmrs.org).

private said...

1. I've contacted BitRock on how to do this, if possible. They have support for changing that sort of thing with the progressText field, but that seems to only apply to user-defined actionLists or the finalPageActionList. The text you are seeing is created by BitRock by default and just substitutes the name of the project into the text string.

2. Duh. I fixed the port issue now, thanks for pointing that out.

3. I'll add this to the list of final polishes.

4. Easy enough, I'll add this right away.

5. I've e-mailed BitRock to see if this is possible. It is a main project option that is set to either 1 or 0, but I'm not sure if BitRock provides a way to garner the exit code from the post-install script. They probably do, so we'll just wait and see what they say.

6. I've also asked BitRock about this. At the start, I left Dirk's html in the License/Readme, but BitRock just ignored them. We'll see what they say, but even BitRock's installer that they made themselves has the same bland plain text.