2010-10-10

Colo and hosting

If you want to pay someone to host your server on the internet, there are 3 ways to go.

  • "Colo"
    Short for Co-located, where you own a computer, send it to a service company, and they install it in their racks. You own the computer box, they plug it into fast internet connections, uninterruptible power supplies with generator backup, and possibly behind firewall hardware. Some will sell you a computer from their inventory as well, new and/or used.
  • Rent-a-server
    Same as above but you rent their computer rather than provide your own. With today's low costs for computing hardware, this may not make financial sense.
  • Virtual Server
    You pay rent for a certain speed and number of processor cores, certain amount of disk space, and bandwidth and/or traffic. But it's all imaginary. You don't actually control a specific computer box, processor, or hard drive. Your virtual server is one of many others operating across a server farm, large arrays of computers. Some services let you shut down your virtual server but store your disk space while reducing the bulk of your cost. This is handy for test machines, or trial runs before launching your full-time servers.
In the first two categories, my professional contacts, previous research, and word-of-mouth leads me suggest the following companies to someone looking for a vendor:
Do your own research and shopping, but those vendors may be a good place to start.

2010-10-08

Zipping beyond the Mac

I distribute my cross-platfrom app to the world as simply a zipped file. That seems to be working well, except for two problems:

  • Older versions of Windows, even Windows XP, may not ship with a Zip tool. 
  • When creating the zip on my Mac using the Finder command File > Compress*, extra files or folders are included for Mac-savvy features. 
The first problem, I have no answer for. Except to say I've gotten no complaints from the public yet. So perhaps the problem is not widespread today.

The second problem is a problem only for the non-Mac crowd. On a Mac, the extra file/folders are invisible. But on Linux and Windows computers, the users see this extra crud and are likely to get confused. I have found 2 easy fixes.
  • Path Finder
    This excellent app from CocoaTech is a Swiss Knife full of diverse tools, handy for a range of geeks and programmers. It costs about forty bucks, and so worth it. Relevant here is the ability to create zips. By default it creates zips in the same Mac-savvy way. To strip that extra stuff in future zips, in Path Finder preferences, turn ON the two "Ignore" checkboxes.
    ☑ Ignore invisible file when compressing
    ☑ Ignore resource forks when compressing

  • YemuZip
    This free app from Yellow Mug does one simple thing: Create zips. Drag-and drop easy. With the option of stripping away the Mac-specific stuff. Perfect. Even includes a feature to check for updates.


* Older versions of Mac OS X: File > Make Archive

2010-10-06

Running Apache Tomcat on your Mac

  

Apache Tomcat is Apache's other web server. Also runs Java Servlets and JSPs. I prefer running Tomcat as a web server much better that Apache's more famous (and finicky) "httpd".

Tomcat is pure Java, so it runs very well on your Mac OS X computer. Apple builds Java into every Mac.

  • The current version 6 runs on many older generations of Macs as well as new ones. 
  • The still-beta version 7 will run only on Java 6, which requires an Intel Mac running Snow Leopard.
There is one big catch to running Tomcat on your Mac: By default, the permissions are set incorrectly on the downloaded files. When you try launching Tomcat you will get errors, complaining that you do not have permission to complete certain operations. The fix is so easy: just a drag-and-drop and a few mouse clicks. Here's how.

Download the free app (donations accepted) BatChmod. It has the best icon, by the way. This app is a very convenient gui wrapper around an otherwise very difficult arcane set of command-line instructions. You will be entrusting your system password to them, and do so at your own risk. They've been in business for years with no issues I've heard of. Tip: To detect any software phoning home without your permission, get the Mac app Little Snitch.

Download Tomcat. Version 6.0.29 is current nowadays. Grab the zipped one, as the tarred files may not work with Mac OS X' tar tools. You'll end up with a folder named something like "apache-tomcat-6.0.29". If you’re paranoid, hit the MD5 link, read the number, then drag and drop the downloaded zip file to a Terminal window after typing "md5 ", and compare your number to theirs. If no difference, you downloaded without corruption.

You can place the Tomcat folder anywhere you like. I avoid nesting too many folders because extremely long path names can cause problems. I suggest the top level of your home folder.
  1. Drag and drop your unzipped Tomcat folder to the BadChmod app. 
  2. Check all the checkboxes except "Clear xattrs".
  3. Click Apply.
  4. Enter your system password.
  5. Quit.

CAVEAT: I am not expert at these Unix permissions and related issues. Do all this at your own risk, and after your own research. I'm just sharing what works for me, but taking no responsibility for you.

This problem of Unix file permissions often occurs on downloaded files, but the effects are more obvious in Tomcat. I usually run BatChmod on anything I download, unless packaged as a .DMG file. 

Now you're ready to launch Tomcat.
  1. Open a window in Terminal app, found in Applications > Utilities folder.
  2. In the Finder, locate inside the "bin" folder inside the Tomcat folder.
  3. In "bin" folder, locate the file named "startup.sh".
    (Ignore the .bat files; those are for MS Windows)
  4. Drag and drop that "startup.sh" to your Terminal window.
  5. Press Return to run that shell script.
    (".sh" means "shell")
  6. See several lines of text appear in the Terminal window.
    (If you see about 5 lines of "Using " this-or-that, you are in good shape.)
Now test your web server.
  1. Launch a web browser, such as Safari, Camino, Firefox, Opera, Chrome, etc.
  2. In the URL address bar, type:
    localhost:8080
    Or if that seems to fail, type:
    127.0.0.1:8080
  3. Press Return to make the web browser hit your web site.
    If successful, you should see a web page displayed with the cute tiger Tomcat logo and the Apache feather logo.
To get rid of the need to add the ":8080" see my other blog post on port-forwarding.

To shutdown the web server, in that same Terminal window, drag and drop the "shutdown.sh" file. Press Return to execute, of course.

Tip: Press the Up-Arrow key to re-enter previously used lines in that Terminal window. Press Return to execute one of them. This is a handy way to easily repeatedly start and stop Tomcat.

If you got this far, lastly you replace Tomcat's default web site with your own. Replace the contents of:
Tomcat folder > webapps > ROOT

Note that we did not do any configuration settings in Tomcat whatsoever. I like that about Tomcat: For a single web site, Tomcat is ready to go out-of-the-box. You can do much more configuration if you wish as Tomcat is relatively flexible and full-featured as web servers go. You can change the port number. You can turn on logging to record who hits your web site and when. You can enable virtual hosting to serve multiple web sites. You can set up security restrictions controlling access to portions of your web site.

In passing, I'll mention another popular Java-based alternative to Tomcat: Jetty. If you want a bunch of additional functionality, beyond just web serving and Java servlets, for a big application server consider Glassfish. But for me and most folks I know, Tomcat or Jetty are the way to go.

Hope that works for you. Happy serving!

Use Google to search REAL Studio docs

I really miss the PDF version of docs for REAL Studio 2010. With PDFs, I can use Apple Preview or Adobe Reader to search through an entire manual to find occurrences not listed in the TOC or Index.

The REAL Studio team has chosen to move from PDFs to online wiki-based docs, for the noble reason of keeping the docs always up to date. Unfortunately, the price we paid is awkward search capability. Unless you are searching for an exact class name, the search utility at docs.realsoftware.com leads to frustration.

Then I remembered the wise man who taught me this nifty trick in using Google: Constrain a Google search to a single domain (web site). Simply add the word "site:" (with a colon) and the domain name. Then add on your usual search criteria.

For example, instead of googling this:
Shared Property
Put this into your Google bar and smoke it:
site:docs.realsoftware.com Shared Property

 

Add a Version Number to Your Classes

When creating classes to be shared with others, add a property to represent the version.

Programmatic access to the version number is good for at least 2 reasons:

  • Review what version is currently installed in an app.
  • Calling code can work around bugs or changes in behavior if it knows the version number.*
At the very least, add a simple string to store something like "2.4".

Make the property a "static" or "class" field with one value shared among all instances. The number will not vary across instances, so there is no need to make it a regular member. In REALbasic, make it a Shared Property.

2010-10-03

Tracking a field's value in REALbasic

Oddly enough, REAL Studio 2010 through Release 3 does not offer an event meaning the user (or code) changed the value in a TextField. On every keystroke, both "KeyUp" and "TextChange" fire. But that is too often. In boring database-backed business apps, we usually don't care about the user's edit as it happens. We only care after the edit, when the change is complete.

Hopefully the REAL Software team will add such an event in the future. In the meantime, I am giving away a single file, a subclass of TextField named "TextField_ValueTracking". I have an example project to demonstrate how it works. See here.

Moving files securely between Macs

How do you move files across a network or Internet to a secure Mac server?


iDisk

As a faithful Apple customer with a MobileMe account, my first thought was to use my iDisk to transfer files. I put files into my "Public" folder, then on the server in the Finder I choose Go > iDisk > Other User's Public Folder. The Finder mounts the public folder as a drive. Works well. Until it doesn't.


Problem

Twice now I've been burned in Mac OS X 10.6.4 and .5 where the Finder gets confused about the mounted iDisk folder. One symptom of this Finder bug is refusing to dismount. The Finder complains that a file is in use, but that's not true. The list of files in the mounted iDisk no longer updates its display to show current contents. "Force ejecting" the mounted iDisk fails. Your only option left is to force-quit the Finder. But that hoses your Mac, requiring a restart of your secure server. That's a drag.

I don't expect a fix soon. The Finder has always been lousy with bugs related to iDisk and its WebDAV protocol. With Snow Leopard, the Finder got a re-write in Cocoa from Carbon, which means new hiding places for bugs.


Workaround

One dead-simple workaround:
Rather than mount the iDisk in the Finder, use a web browser. 

Apple has been greatly improving the web access to MobileMe features. That includes iDisk file access. A nice multi-columned view of the file system appears in your web browser when you access the iDisk icon.

To log in to your MobileMe account with full access:
http://www.me.com/

To access somebody's iDisk public folder, point your web browser to:
http://public.me.com/TheirUserNameGoesHere

By the way, there are some other handy such URLs for accessing a MobileMe account's picture gallery, calendars, and web site.

You may be able to use Safari or other web browsers such as Camino, Firefox, Chrome, or Opera. I've some of those successfully, but don't recall which. You may get a warning message, but I've ignored it with no penalty.