Create a gist now

Instantly share code, notes, and snippets.

@pims /example.nomad Secret
Created Feb 29, 2016

What would you like to do?
Simple Nomad job specification & http service written in Go.
job "nomad-example" {
region = "us"
datacenters = ["dc1"]
type = "service"
group "webservice" {
count = 3
task "app" {
driver = "raw_exec"
config {
command = "/Users/tim/codebin/go/src/github.com/pims/nomad-example/nomad-example"
}
resources {
network {
mbits = 1
port "http" {}
}
}
}
}
}
package main
import (
"fmt"
"log"
"net/http"
"os"
)
func endpoint(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "%s\n", "hello world")
}
func main() {
// addr := ":8888"
addr := os.Getenv("NOMAD_ADDR_http")
http.HandleFunc("/", endpoint)
log.Println("Listening on:", addr)
err := http.ListenAndServe(addr, nil)
if err != nil {
log.Fatal(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment