Archive for the ‘Fantom’ Category

Provision Fantom for Vagrant

Tuesday, August 12th, 2014

Vagrant is an awesome tool for anyone who needs to develop or test against predictable OS configurations. If you’ve never played with – definitely check it out:

If you have a Linux box, the steps below will get Fantom up and running. These steps are for Debian/Ubnutu – so you may need to tweak for other distros.

1. Init your box

For this tutorial we’ll use the built-in Ubuntu box:

$ mkdir example
$ cd example
$ vagrant init hashicorp/precise32

2. Configure your Vagrantfile

Edit your Vagrantfile to add a provision step:

# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| = "hashicorp/precise32"
  config.vm.provision :shell, path: ""

  # any other config you need


3. Add your script

Add a script in the same directory as your Vagrantfile:

#! /bin/bash

quiet() {
  # if provision is failing uncomment/comment to see full output
  "$@" &> /dev/null

# Unzip
echo "Install unzip..."
quiet apt-get install unzip

#   To install another version update 'JAVA_VER'
#   For example: JAVA_VER="7"
#   Note: if you use JDK7+ for compiling, then any compiled Fantom
#   pods will require a Java 7 or later runtime.  If you wish to target
#   Java 1.5 or 1.6 runtimes then you must use JDK 1.6 (JAVA_VER="6")
echo "Install JDK $JAVA_VER..."
echo "deb precise main" \
  >> /etc/apt/sources.list
echo "deb-src precise main" \
  >> /etc/apt/sources.list
echo "debconf shared/accepted-oracle-license-v1-1 select true" \
  | debconf-set-selections
echo "debconf shared/accepted-oracle-license-v1-1 seen true" \
  | debconf-set-selections
quiet apt-key adv --keyserver --recv-keys EEA14886
quiet apt-get update
quiet apt-get -y -f install oracle-java${JAVA_VER}-installer

# Fantom
#   To install a different version of Fantom update 'FAN_VER'
#   For example: FAN_VER="1.0.64'
echo "Installing Fantom ${FAN_VER}..."
wget -q$FAN_ZIP
unzip -q $FAN_ZIP -d /opt
mv /opt/fantom-$FAN_VER /opt/fantom
bash /opt/fantom/adm/unixsetup
echo "export PATH=$PATH:/opt/fantom/bin/" >> /etc/profile
rm -f $FAN_ZIP

4. Boot your box

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'hashicorp/precise32'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'hashicorp/precise32' is up to date...
==> default: Setting the name of the VM: linux-arm_default_1407852247628_86495
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address:
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default: Guest Additions Version: 4.2.0
    default: VirtualBox Version: 4.3
==> default: Mounting shared folders...
    default: /vagrant => /Users/andy/example
==> default: Running provisioner: shell...
    default: Running: /var/folders/2v/0phd0cks4t1d4922gq7yl6kw0000gn/T/
==> default: stdin: is not a tty
==> default: Install unzip...
==> default: Install JDK 6...
==> default: Installing Fantom 1.0.66...
==> default: ###
==> default: ### FAN_HOME=/opt/fantom
==> default: ###

5. SSH in and Happy Fantom-ing!

$ vagrant ssh
vagrant@precise32:~$ fan -version
Fantom Launcher
Copyright (c) 2006-2013, Brian Frank and Andy Frank
Licensed under the Academic Free License version 3.0

Java Runtime:
  java.version:    1.6.0_45    Java HotSpot(TM) Client VM
  java.vm.vendor:  Sun Microsystems Inc.
  java.vm.version: 20.45-b01
  java.home:       /usr/lib/jvm/java-6-oracle/jre
  fan.platform:    linux-x86
  fan.version:     1.0.66
  fan.env:         sys::BootEnv
  fan.home:        /opt/fantom

Fantom wrapper for Mailgun

Wednesday, April 17th, 2013

Posted a Fantom wrapper for Mailgun. Has first-class support for basics (send, unsub, spam, bounces, logs, stats). But really simple to work with raw REST API too.

The Fantom Linode Guide

Wednesday, February 27th, 2013

I’ve stubbed out a basic guide for getting Fantom up and running on Linode. Its a bit of a work in progress – but mostly gets you from start to finish:

  • Installing Fantom on Debian
  • Setting up init scripts
  • Configuring ngnix as proxy server
  • Setting up automated deployments

Its hosted on BitBucket – so feel free to send me pull requests if you have corrections or improvements (I’m by no means a linux guru…):

init.d example for Fantom

Wednesday, August 15th, 2012

Update 27 Feb 2013 – While this should still be valid advice – it’s been superseded by a more comprehensive guide covering the whole process of getting Fantom up and running on Debian:


Been meaning to post this for awhile. Below is the init.d script I use to run Fantom on my personal sites. I’m running Debian 6 – but should be straightforward to tweak for other distros. Might need to apt-get a few things like pgrep – can’t remember what came out of the box.

A few caveats:

  1. I always install and run each “app” using a dedicated user with its own Fantom runtime. I find this really simplifies security, process management, and versioning. This example uses the fan user.
  2. This script should properly block until process cleanly exits. But don’t have a good way to know when start is complete – so just waits a few seconds. You can tweak depending on your app.
  3. This script redirects stdout and stderr to the same log file. You can tweak as necessary.
  4. I’m using a script ( to launch my site. But you can launch Wisp or another main directly from bash string.

Example server layout:

    ~/               User home directory
      fantom/        Fantom runtime
      dist/          App path env
        fan.props    Empty fan.props to force PathEnv
        lib/         PathEnv lib for App

Example init.d script for Fantom:

    #! /bin/bash
    # /etc/init.d/example

    FIND_PID="pgrep -u fan java"

    case "$1" in
        PID=$( $FIND_PID )
        if [ -f $PID ]; then
          echo "Starting"
          sudo -u fan bash -c  'cd ~/dist; ~/fantom/bin/fan &' &> $STDOUT
          sleep 3
          echo " is already running"
        echo "Stopping"
        PID=$( $FIND_PID )
        if [ -f $PID ]; then
          echo " is not running"
          kill $PID
          while kill -0 $PID 2> /dev/null; do
            sleep 0.5
          echo "stopped"
        PID=$( $FIND_PID )
        if [ -f $PID ]; then
          echo " is not running"
          echo " is running"
        $0 stop
        $0 start
        echo "Usage: /etc/init.d/example {start|stop|restart|status}"
        exit 1

    exit 0

Markdown for Fantom

Sunday, February 5th, 2012

Sunday Funday project for today – Markdown for Fantom:

Markdown is a great little plain-text format created by John Gruber that converts nicely to HTML. Fantom’s own Fandoc was heavily inspired by Markdown. We just simplified a few things and added some Fantom conventions in a few places. But I’ve wanted the full Markdown syntax at my disposal for some time now.

Luckily it was a pretty simple project – I was able to essentially take the great Markdownj work as-is and wrap with a native Fantom API. Code is available over at BitBucket and is licensed under the BSD license.

LESS for Fantom

Sunday, January 22nd, 2012

I worked up a Fantom wrapper around LESS this week. Code and docs over on BitBucket:

LESS is a great little “extension” to CSS that adds lots of convenient features like variables, mixins, and nested rules that make developing and managing complex CSS much easier.

The Fantom wrapper adds:

  • An API interface to compile LESS files from a Str input or a File reference
  • A simple command line interface for compiling LESS files to CSS files
  • A BuildTask for integrating LESS into your Fantom build pipeline

Draft Mini Web Framework

Sunday, July 24th, 2011

I’ve posted a project I’ve been working on in my spare time recently:

Draft Mini Web Framework

Draft is a small web framework designed to notch in above WebMod, provide some useful features, while trying to leave as much freedom as possible for your app. Details over on the project site.

Its still a work in progress, but decided it was far enough along to start being useful to anyone who doesn’t mind getting their hands dirty. Hopefully I’ll have it wrapped up here in the next few months, and can be more generally useful to developers looking for a simple and lightweight solution for developing web apps in Fantom.

Sketching Logos

Wednesday, January 5th, 2011

Was flipping thru an old moleskin and found two sketches I made back in Fall 2009.

Fantom logo sketch

First was a little sketch of a potential logo for the Fantom language. For whatever reason, when we changed the name to Fantom, I got this 1920s/Art Deco motif concept in my head (hence the typeface). I’m pretty sure its because of the movie The Shadow, but I keep trying to tell myself thats not the case… Never really had time to come up with a real logo — but this is one I sorta liked.

Axon logo sketch

Second was a logo for the Axon scripting language we designed for our day job at SkyFoundry. Would love to give these both some good Photoshop treatment if I ever find the time.

Blue Collar Languages

Monday, September 27th, 2010

Cay Horstmann wrote an interesting response to Stephen Colebourne’s NBJL post:

Creating a “blue collar” language isn’t something that happens every day.

When done by “blue collar” people who have sketchy knowledge of programming language theory, the result is often problematic. Look at PHP–I trust that I won’t have to elaborate… Or Groovy, many of whose properties (particularly in the MOP) are under-specified and constantly shifting.

Few “white collar” people have an interest in designing a blue-collar language. They give us languages that dazzle us with their brilliance and innovation. After all, that’s what a researcher is rewarded for.

Interestingly he made no mention of Fantom in this context, which means I assume he hasn’t looked at it any detail. That was one of the explicit design goals.

Which makes me wonder – do people pass over Fantom because of the exact same reasons they search for new languages? You want a simpler, more expressive language, with great APIs, that make your life easier 9-5. But you take a look at Fantom, and move right along, since you don’t see buzzwords like monads, or some ground breaking new syntax?

Fantom’s History and Future with JavaScript

Wednesday, June 2nd, 2010

One of Fantom’s primary design goals from day one was portability between the JVM and CLR. Naturally we got to thinking, if we can run on both of the popular VM’s, why not on JavaScript too? That would enable enormous opportunities for code reuse and greatly simplify the huge impedance mismatch of developing backend server code and user interfaces in the browser.

Read the full post at