davidbanham / field-marshal

A landlubbing rear-admiral
BSD 3-Clause "New" or "Revised" License
27 stars 3 forks source link

Field Marshal

Field-Marshal is an open source, simple, private PaaS you can run yourself. It's a lot like Heroku, but it runs on your own computers. These might be machines in a datacentre, or they might be AWS instances. It's up to you.

Field Marshal is designed to make it easier to manage Service Oriented Architectures in the wild. It's born out of years of experince running and administering SOAs with other tools.

Field Marshal is an SOA itself. All components speak to each other via a well-defined API, so you're free to replace bits if you like. Field Marshal is designed to work with Cavalry, which does the work of routing the web requests and runing the proceses. One Field Marshal instance controls many Cavalry instances.

You may also be interested in Quartermaster, which is a graphical administration tool.

The way it works is:

  1. You run one or more Cavalry slaves on different servers.
  2. You git push your code to Field-Marshal.
  3. You tell Field-Marshal how many of each of your services you want to run, how they should be started, and where people look for them.

Field-Marshal takes care of the rest, getting the code to the slaves, setting up the code, routing the http traffic, respawning instances if they die, re-allocating the jobs if a slave goes down.

You can hear me talk about the way Field Marshal works on youtube. This is a recording of a presentation I gave at a nodeJS user group in Sydney.

Build Status

In the wild

The biggest installation of Field Marshal to date is at Pinion. The cluster there serves around 10k requests per minute across various different services.

Getting Involved

I ❤ pull requests. Feel free to log a github issue if there's something you'd like.

Installation

There is a video of an installation walkthrough I gave at a user group - Video Walkthrough

npm:

npm install -g field-marshal

git:

git clone https://github.com/davidbanham/field-marshal
npm install

Port 4000 and 4001 will need to be accessible by the slaves to check in and fetch code.

If you install globally, field-marshal will look for manifests and store repositories in the directory it's run from.

Running it

Configuration paramaters are passed in via environment variables. eg:

CAVALRYPASS=cavalrypassword HOSTNAME=localhost SECRET=password node index.js

If they're not present, a default will be substituted.

The manifest is one or more JSON files in the manifest directory. An example is:

    {
      "beep": {
        "instances": "*",
        "load": 1,
        "routing": {
          "domain": "beep.example.com"
        },
        "opts": {
          "setup": [
            "npm",
            "install"
          ],
          "command": [
            "node",
            "server.js"
          ],
          "commit": "8b7243393950e0209c7a9346e9a1a839b99619d9",
          "env": {
            "PORT": "RANDOM_PORT"
          },
          killable: false,
          killTimeout: 300000,
          prunable: false
        }
      }
    }

Variables of note are:

Getting your code into it

Field-marshal starts a git server on port 4001. Just push to it!

git push http://git:testingpass@localhost:4001/beep master

Authenticate with whatever you set in the SECRET environment variable. Here we've called the repo 'beep'. Each repo needs to have a unique name so you can refer to it later.