mattyw

talkative, friendly, programmer

Go Binary Charm Layer

| Comments

I like go. One of the things I like is not worrying about dependencies during deployment. You just scp your binary to your server and you’re done. Well, after you configure it to connect to the database, ah yes, we forgot about haproxy, let’s set that up as well, but after scping to a server and doing some minor setup you’re ready to go, scale it out you say? Just scp to other servers, do the same config setup……..

The solution to this problem is to use an orchestration tool like juju. Now thanks to the go binary layer orchestrating your go program with juju couldn’t be easier.

Here’s how it works. The go-binary layer looks in the top level of your charm for a go-binary.yaml file that contains the name of your binary and any arguments that should be passed to it.

1
2
3
#go-binary.yaml
binary: server
args: /etc/myserver/config.yaml

Your compiled binary should be placed in a “files” directory at the top level of your charm. Build your charm and you’re all done.

1
2
3
4
5
6
7
$ tree
.
├── files
│   ├── server
├── go-binary.yaml
├── layer.yaml
├── metadata.yaml

Under the covers the go-binary layer will add your binary to $PATH,write an upstart file for your binary and start it when the server starts.

There are examples of this in action with the http (website) relation (https://github.com/mattyw/simple-server-charm)

and with the mongodb relation (https://github.com/mattyw/simple-server-mongo-charm).

If you’d like to see these charms in action take a look at the following videos:

Comments