-
-
Save pims/cd9d8982479acd24b665 to your computer and use it in GitHub Desktop.
Simple Nomad job specification & http service written in Go.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" {} | |
} | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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