Skip to content
This repository has been archived by the owner on Mar 14, 2020. It is now read-only.

Commit

Permalink
Merge pull request #4 from stripe/index-fix
Browse files Browse the repository at this point in the history
Load index.html from static/
  • Loading branch information
jbalogh committed Nov 22, 2014
2 parents d704564 + 2bb2aae commit e4337b6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
static
static/js
static/css
static/img
bin
node_modules
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ node_modules:

clean:
rm -f timberlake timberlake-*.tar.gz
rm -rf static bin node_modules
rm -rf static/{js,css,img} bin node_modules
rm -rf $(RELEASE_NAME)

.PHONY: clean build release
20 changes: 13 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ var yarnLogDir = flag.String("yarn-logs-dir", "/tmp/logs", "The HDFS path where

var jt jobTracker

var rootPath, staticPath string

func index(c web.C, w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "index.html")
http.ServeFile(w, r, filepath.Join(staticPath, "index.html"))
}

func getJobs(c web.C, w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -95,6 +97,16 @@ func killJob(c web.C, w http.ResponseWriter, r *http.Request) {
}
}

func init() {
binPath, err := filepath.Abs(filepath.Dir(os.Args[0]))
if err != nil {
log.Fatal(err)
}

rootPath = filepath.Join(binPath, "..")
staticPath = filepath.Join(rootPath, "static")
}

func main() {
flag.Parse()

Expand All @@ -110,12 +122,6 @@ func main() {
sse := newSSE()
go sse.Loop()

binPath, err := filepath.Abs(filepath.Dir(os.Args[0]))
if err != nil {
log.Fatal(err)
}

staticPath := filepath.Join(binPath, "..", "static")
static := http.StripPrefix("/static/", http.FileServer(http.Dir(staticPath)))
log.Println("serving static files from", staticPath)

Expand Down
File renamed without changes.

0 comments on commit e4337b6

Please sign in to comment.