4
Aug/09
3

Deploying an Erlang Appliance with SUSE Studio

Having read Nat Friedman’s blog post about the release of SUSE Studio, I thought I’d take a look at it. I was also interested to find out how easy it is to create an appliance for a simple Erlang application.

suse-studio

An Introduction to SUSE Studio

I’m very impressed with SUSE Studio. It allows you to completely customise a Linux distribution and actually try it out (in the browser!) before you download it. This is, in my opinion, a pretty novel concept. At least at this scale.

Being able to have this control before you download the distribution obviously saves you from downloading a load of components that you don’t want. But the benefits don’t stop there:

  • Performing the administrative tasks of setting up the system can be performed before installation. This means a system can be deployed many times with minimum effort. Products like Xen and VMware provide cost-effective ways to host several different systems together and keep them isolated from each other. If one of your applications breaks, the others are (potentially) isolated from the problem.
  • Applications can be deployed and run in a pre-specified environment. This means their behaviour will be more predictable, and it will be easier to provide support for them. If a client is reporting problems, it will be much easier to replicate them yourself in a test environment.

My Experiences with SUSE Studio

The service is currently by invite only. But having filled out the form, I got an invite the next day:

Thank you for your interest in SUSE Studio, a new service that makes it quick and easy to create and test software appliances from your web browser. We are pleased to invite you to try SUSE Studio.

Sign in is via OpenID, which is nice.

The interface is very smooth and pleasant to use. Helpful messages appear in the left-hand column, which let you know where you’ve gone wrong, or give you tips as you go, and there’s a helpful ‘undo’ feature. The site is also scattered with a selection of pleasing cartoons.

The ‘test drive’ feature is awesome. Once you’ve finished configuring the system you need to build it, which takes a little time. When this is completed, just click on ‘Testdrive’, and a flash applet lets you watch the machine and interact with it (via VNC). Nat has an article about some of the implementation details.

By enabling networking in test drive, you can also connect to the machine via SSH, or with your web browser if there’s a web server running.

Whilst Test Drive is running, you can even see a list of the files that have been modified, view diffs and download the modified files.

A impressive number of configuration parameters are at your disposal. You can even personalise the system by changing the logo and background image.

I noted a minor problem with the interface so I sent some feedback to the developers to check they were aware of it. I was impressed that they replied to me about ten minutes later (to say they were aware of the problem, thanks).

Setting up an Appliance with Erlang

The steps involved in setting up a basic appliance are very simple. I’ll skim over these steps and instead focus on those involved in setting up Erlang, and adding your application to the appliance. The aim is to have an Erlang application boot automatically when the appliance is started.

I started off with the openSUSE 11.1 ‘just enough’ base template, which, for reference, has the following packages installed:

aaa_base, branding-openSUSE, dhcpcd, grub, hwinfo, insserv, kbd, kernel-default, licenses, mkinitrd, module-init-tools, netcfg, openssh, openSUSE-build-key, openSUSE-release, PolicyKit, polkit-default-privs, procps, pwdutils, rpcbind, rpm, sysconfig, syslog-ng, vim

The next step is to add a repository that contains the Erlang package. Select ‘Add repositories…’ from the Software page, search for ‘erlang’ and then add the suggested ‘devel:languages:erlang 11.1′ repository. At time of writing, this will install Erlang release R12B-5.

Then, from the software page, search for ‘erlang’, and select the ‘erlang’ package to be added.

Then make a few more configuration changes as required—for example, selecting the keyboard layout and time zone, and adding users (with default passwords that should obviously be changed following installation).

The next step is to add the Erlang application. I won’t go into details of setting up OTP applications, but I will explain how to automatically generate a bootable release file.

The release file needs to be setup to work with the installed version of Erlang, and the boot script needs to be generated in the same system environment (so we know we’ve got the correct versions of applications). To achieve this, I have written an Erlang script to be run when the appliance is first booted, which will generate a release file and accompanying boot script.

The main function that generates the release file is:

generate_release(Name, Version, Apps) ->
    ErtsVsn = erlang:system_info(version),
    lists:foreach(fun(App) -> application:load(App) end, Apps),
    AppsVsns = lists:map(fun(App) -> {App, get_app_vsn(App)} end, Apps),
    {release, {Name, Version}, {erts, ErtsVsn}, AppsVsns}.

Download the complete script to try it out.

The application I am deploying is a simple echo server, but I won’t go into details here.

You need to package up your application (possibly including the compiled make_release.erl script), then upload it under the ‘Overlay files’ section, and specify a directory to extract the files to. I put the application into /usr/local/, and use the following directory structure:

directory-structure

(Note that the echo-1.0.* files wouldn’t be there when uploaded as they get generated by the script.)

If you’d like the application to be started when the system boots, you may wish to add this to a boot script. Boot scripts can be configured under the ‘Configuration’ section. The following boot script will generate the release file when the system is booted for the first time. Following this, and on subsequent boots, the the Erlang application will be started.

My boot script looks like this:

if [ -f /etc/init.d/suse_studio_firstboot ]
then
  # Generate release for Echo Server
  echo "Generating release for Echo Server..."
  erl -noshell -s make_release -pa /usr/local/Echo-1.0/ebin/
fi
 
# Start the echo server
echo "Starting Echo Server..."
erl -boot echo-1.0 -pa /usr/local/Echo-1.0 -detached

If you’re wondering, it looks like this script gets installed to: /etc/init.d/suse_studio_custom

I installed the ‘open-vm-tools’ package, as suggested (since I had specified that I wanted to generate a VMware virtual machine), and then set the machine to be built.

The appliance took a few minutes to build.

(Having requested a few more builds, it turns out that there’s a queueing system, so you may get lucky, or you may be in for a wait…)

Once the build was complete I was able to try it out in the browser:

test-drive

After downloading it, double-clicking the .vmx file booted the machine in VMware:

vmware

I was then able to test out the Erlang application by connecting with telnet:

echo

Alternative Approaches

An alternative to actually installing your application is to just setup an appliance that has Erlang installed. This would still ease the setup process of the system and would just require you to add your Erlang application in after installation.

If you wanted the latest version of the Erlang system, it might be possible to upload the latest Erlang release as an ‘overlay file’, as opposed to fetching it from the repository. The benefit of using the repository is that it could be set to update automatically.

Filed under: Erlang, Linux
Comments (2) Trackbacks (1)
  1. crazyfunkydude
    10:34 pm on August 5th, 2009

    Hey! When will i get my e-mail from Suse Studio? I have been waiting like 3 days!!!!!!!!

  2. Joe
    10:52 pm on August 5th, 2009

    I got mine the day after I requested it. Did you fill out the questionnaire? Maybe I just got there before the Slashdot crowd—perhaps there’s a bit of a backlog.

Leave a comment