OS X and Liferay tip

It's been exactly 10 years since I got my very first computer, which was on Christmas of '97, and was a $400 dollar IBM clone, running Windows  95. I didn't even know how to change my wallpaper, or use my computer for anything more than a CD player/Calculator/Solitaire machine.

It's odd that exactly 10 years after getting my first computer, I am reaching another first, and that is my first Mac.

I have made the switch, and I am sold.

There has been some small issues, like a lack of decent freeware, and a few little oddities, but overall, it's been incredibly pleasent.

One of the things I love is the fact that it's based on FreeBSD, and it means I have a file system that actually closely mirrors the web servers I've been used to developing on.

But one thing I missed from Windows was shortcuts to my different Liferay installations. Clicking on startup.bat would load a new command propmpt window, which would show the log in that window.
Unfortunately, in OS X, when you run startup.sh from the command line, it doesn't do that. Basically, the normal workflow is:
Navigation to your Tomcat/bin directory
run startup.sh
run tail -f ../logs/catalina.out

Kind of a pain, if you ask me. Brian Chan also taught me that you can shorten that a bit by just using './catalina.sh run', however, I think this could be improved a bit too.

So, what I did was created an alias called liferay that runs that does just that. This way, I can just run the command from anywhere, and it will launch Liferay right there, and show the catalina.out log.

Of course, there could be better ways to do this, and I would love to hear them. I am a relative n00b on the Mac, so I am sure there will be some cool optimizations and the like that I won't get.

So here's how you can quickly create the alias:

  1. Open Terminal
  2. Type 'pico .bash_profile'
  3. If there's anything in the file that opens up place the following line at the end, if not, just place it at the first line:
    alias liferay='~/Desktop/Development/Tomcat/bin/catalina.sh run'
  4. Replace the path above with the path to your tomcat directory.
  5. Press Ctrl X, and then hit Y when it asks you if you want to save, then press enter
  6. At the command line, type 'source .bash_profile' to refresh your profile
  7. Type liferay to launch Liferay from the command line.

Now, you can always just use the liferay command, and just press Ctrl C to exit out.

I will be playing with some ways to manage a bunch of different bundles and be able to launch them easily without having to navigate the file system via CLI everytime I need to launch one.

 

Blogs
I don't know if this is more desirable, but you could just modify ./bin/catalina.sh to achieve the same effect. Open up ./bin/catalina.sh, and scroll down to line 269 and line 281.

You'll notice that these lines tell the shell to (a) redirect the output to /logs/catalina.out and (b) run Java as a background process. Just get rid of those lines (and the backslashes on the preceeding lines), and Tomcat should run just as it does on Windows.