Chad Remesch bio photo

Chad Remesch

Entrepreneur, software engineer, and photographer.

Email LinkedIn Instagram Github

I've released my latest Ruby gem named Cron Helper to make life easier for those Ruby & Rails projects that use Cron. It's designed to build on top of the Whenever gem to solve a number of common problems I've encountered over the years. Features include:

Overlapping job prevention: Cron will allow overlapping jobs and this can result in race conditions, resource starvation, and other problems since web developers usually don't encounter them on their development environments. An example of this is an hourly job that starts taking two hours to complete. Cron Helper uses file locking to prevent overlapping jobs since the general rule of thumb is that a longer running job is a better situation to have than a buildup of overlapping jobs.

Tasks: Think of tasks as methods you want to execute when a specific job runs (such as an hourly job). Tasks execute one by one in a guaranteed order within a job. They also provide exception handling so that a failed task won't prevent the tasks after it from running. This gives you fine grained control over how and when code should execute. It also helps prevent resource starvation by encouraging developers to limit the number of concurrent Ruby processes.

Controlled concurrency: In Cron Helper terms, tasks prevent concurrency and jobs permit it. For exmaple, you could create two separate hourly jobs each with ten tasks. Each job only makes guarantees about the tasks that it controls. Tasks in different jobs may end up running concurrently depending on how you schedule them.

Productivity: Traditionally, creating cron jobs was a sysadmin task on a server. One of the great advantanges of the Whenever gem is that it gave this capability to the app developer by making it a first class concept in Rails. Cron Helper builds on on top of this by helping to prevent developers from shooting themselves in the foot. Typically an app has a few jobs on a specific schedule (hourly, weekly, daily, etc). Once these schedules are created, a developer can simply register a new task in the correct one.

Logging: Cron Helper makes it easy to capture all output in a job (stderr & stdout) and decide what to do with it. You have the freefrom to log it locally, send it to a remote service, or simply print it to stdout (the default behavior). Since it's written in Ruby, you also have the power to manipulate it, use regular expressions, or write any other custom logic that your project requires.