|Going Go: Running Go Programs in IronWorker|
We came across a great post by William Kennedy on running Go tasks in IronWorker. It’s a detailed article that had a few of our developer evangelists a bit envious in the care and detail it takes in walking developers through the process. (Using IronWorker is not difficult at all but the post still explains things at a simple, smooth pace.)
William writes Going Go Programming which is a great resource for things Go related.
We’re fans of the Go language (and Going Go). Not surprising, given we’ve been using Go in production for much of our backend for over two years (you can read about that here and here). We also run the GoSF meetup group which lets us connect with top Go developers in the city and around the world.
We can talk at length about IronWorker and its ability to run dynamic languages such as Ruby, Python, Java, Python, Node.js, or .NET as well as binaries and compiled languages like Go. But we do that a lot and so we’d like to pass the baton to William and share his thoughts.
|G+: William Kennedy|
Running Go Programs In IronWorker
Iron.io has a product called IronWorker which provides a task oriented Linux container that you can run your programs inside. If you are not sure what I mean, think of this as having a temporary Linux virtual machine instantly available for your personal but short term use. IronWorker allows you to load your binaries, code files, support files, shells scripts and just about anything else you may need to run your program in the container. You specify a single task to execute, such as running a shell script or a binary and IronWorker will perform that task when requested. Once the task is complete, IronWorker will tear down the container as if it never existed.
[some information about configuring local environment]
The Test Program
I have built a test application that we are going to run in IronWorker. To download the code and the IronWorker support files, run the following commands:
cd $HOME export GOPATH=$HOME/example go get github.com/goinggo/ironworker
This will copy, build and install the code into the example folder under $HOME. The program has been written to test a few things about the IronWorker Linux container environment. Let’s review the code for the program first and test it locally.
For IronWorker to be really effective you want to build programs that perform a specific task. The program should be designed to be started on demand or on a schedule, run and then be terminated. You don’t want to build programs that run for long periods of time. The test program runs for 60 seconds before it terminates.
There were two things I wanted to know about IronWorker that the program tests. First, I wanted to know how logging worked. Second, I wanted to know if the program would receive OS signals when I requested the running program to be killed.
[some code samples for testing Go tasks]
I just scratched the surface with how you can use IronWorker to run your applications. This is a really flexible environment with really no restrictions. You have access to download and install any packages you need, access to the local disk and integration to PaperTrail and a few other logging systems.
Though you don’t need a Linux VM to use IronWorker, you may want to consider having one so you can stage and load your binary programs directly. Again, you have the flexibility to use IronWorker as you see fit.
I hope you try out the service. Use my application or build your own. Post a comment about your experience and anything new your learn. I plan on using IronWorker for two projects I am working on and expect only great things.
To sign up for IronWorker, head to Iron.io and create a free account (it comes with a bunch of free hours per month.)
To get more information on IronWorker capabilities, check out our Dev Center.
To send a note of thanks to William Kennedy or comment on the post, head to his G+ page.