Orange is my favorite color

I’ve written a handful of times on observing and tuning the JVM using tools such as Jstat. I recently upgraded our servers to Java 8 and found that my Jstat script could no longer find the process no matter what I tried.

It turns out there is a bug from JDK 1.7 u75 onwards that is present at least through JDK 1.8 u60 which prevents Jstat, when run as root, from introspecting JREs running as other users.

To solve, simply run jstat as the user who owns the JRE process. You can pass the username to sudo when running jstat like:

sudo -u nobody jstat -gcutil -t <pid> 1s 30

And you’ll be treated to your output again. In my case, I have two server instances running so I like to see their output side by side at the console. Here’s my script for doing that using /usr/bin/paste and some console redirection trickery:

The username can be figured out from the process but this was a quick fix for the above bug.

I’ve been modernizing our development environment and started with the work by Bill Rawlinson to create a portable ColdFusion Docker image. If you’re new to Docker and the benefits of containerization, read up why Docker is dominating 2015. We have Docker Compose running a stack with ColdFusion, Nginx, Postgres, ActiveMQ and Redis all linked together and the entire setup can be started with one command:

docker-compose up -d

I’m simultaneously moving from a Windows machine to a Mac and I’ve been really missing the console logging for watching application activity and errors. It’s easy when installed locally to tail the coldfusion-out.log file but once containerized you don’t have that luxury (without using docker exec to log in to the running container which is a bad practice). The issue is on Linux, ColdFusion has no option to log to stdout like on Windows. As a result, the docker logs command can’t see the output from ColdFusion once the container is running.

It turns out there is a very simple and very elegant way to force ColdFusion, or any app which wants to daemonize and write to log files, to write to stdout. From this ServerFault thread referencing the Nginx Dockerfile, you can symlink the coldfusion-out.log file to /dev/stdout:

ln -sf /dev/stdout /opt/coldfusion10/cfusion/logs/coldfusion-out.log

My Dockerfile for ColdFusion has these two lines:

# redirect logs so `docker logs -f <container>` works
RUN ln -sf /dev/stdout /opt/coldfusion10/cfusion/logs/coldfusion-out.log
RUN ln -sf /dev/stderr /opt/coldfusion10/cfusion/logs/coldfusion-err.log

Now the logs can be collected and observed in a centralized location using Docker best practices.

Update – Slides from my talk were posted on SlideShare. Thanks to everyone who came and all the tweets!

I’ll be speaking at dev.Objective() this year in Minneapolis on a hybrid business/programming topic titled, “Building Multi-Tenant Software-As-A-Service (Saas) Applications” This will be a comprehensive review covering the hurdles I’ve crossed growing from a one-man nights-and-weekends operation to a team that has processed more than $100,000,000 in event entry fees. The talk will cover:

  • Database design and tenancy model trade-offs
  • Third party services and designing for resiliency
  • E-commerce strategies for cards on file, split payments, multiple currencies and marketplace-style apps
  • Implications of going global including i18n, l10n, currency and domiciling
  • Cross-customer security and the impact of banking and legal requirements such as PCI DSS, IRS and Know-Your-Customer (KYC)
  • Code strategies for implementing customer or domain-specific functionality without a “kitchen sink” user experience problem

Developers who are interested in SaaS apps or have the entrepreneurial itch themselves will walk away with a roadmap of the issues a SaaS app must solve and strategies to achieve success. I’ll be speaking immediately after the keynote Wednesday morning, May 13, at 10:15am.

This is my second time attending dev.Objective() and I’m returning because I got a ton of value from it. I hope you’ll consider attending if you’re not already signed up as it will be a positive boost for your creativity and skills. Registration is still available for $999.

Connect with me on twitter ahead of the conference to keep in touch at @ghidinelli. You can connect with other speakers and attendees on Lanyrd

Mark Greene from Cars Yeah interviewed me last week on business, cars and lessons learned. We talked about what got me into cars in the first place, the one car I would buy if money was no object and what has me excited about the future of

Brian Ghidinelli interview on Cars Yeah

It was a lot of fun! Mark has interviewed hundreds of interesting business and motorsport personalities and to be included on the list is an honor. Be careful – you might spend all day listening!