Skip to content

Commit

Permalink
Allow setting port via command line
Browse files Browse the repository at this point in the history
  • Loading branch information
mkobaly committed Jun 22, 2019
1 parent 592d9a3 commit 6f489e3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 27 deletions.
14 changes: 13 additions & 1 deletion cmd/jiraworklog/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"errors"
"github.com/mkobaly/jiraworklog/job"
"strconv"
//"github.com/mkobaly/jiraworklog/test"
"net/http"
"os"
Expand Down Expand Up @@ -37,6 +38,8 @@ func main() {
cmdline.AddOption("c", "config", "config.yaml", "path to configuration file")
cmdline.AddOption("r", "repo", "BOLTDB", "specific repo to use (MSSQL, BOLTDB)")
cmdline.SetOptionDefault("r", "BOLTDB")
cmdline.AddOption("p", "port", "8180", "default port to serve rest API from")
cmdline.SetOptionDefault("p", "8180")
cmdline.AddFlag("v", "verbose", "verbose logging")
cmdline.Parse(os.Args)

Expand Down Expand Up @@ -66,6 +69,15 @@ func main() {
}
}

//Port
port := 8180
if cmdline.IsOptionSet("p") {
port, err = strconv.Atoi(cmdline.OptionValue("p"))
if err != nil {
logger.WithError(err).Fatal("port must be numeric")
}
}

//Repo Settings
repoType := "BOLTDB"
if cmdline.IsOptionSet("r") {
Expand Down Expand Up @@ -101,7 +113,7 @@ func main() {
mux.Handle("/issues/accuracy", http.HandlerFunc(server.GetIssueAccuracy))
//mux.Handle("/", http.StripPrefix(strings.TrimRight("/dashboard/", "/"), fileServer))
mux.Handle("/", fileServer)
go http.ListenAndServe(":8180", mux)
go http.ListenAndServe(":"+strconv.Itoa(port), mux)

select {
case sig := <-c:
Expand Down
27 changes: 1 addition & 26 deletions web/worklogs.html
Original file line number Diff line number Diff line change
Expand Up @@ -188,32 +188,7 @@ <h4 class="text-center">Historical Hours Worked per Week</h4>
}
});

// var chart2 = c3.generate({
// data: {
// json: [
// { developer: 'andrew', day: 'Monday', timeSpentHrs: 6 },
// { developer: 'andrew', day: 'Tuesday', timeSpentHrs: 7 },
// { developer: 'andrew', day: 'Wednesday', timeSpentHrs: 8 },
// { developer: 'andrew', day: 'Thursday', timeSpentHrs: 7.5 },
// { developer: 'bob', day: 'Monday', timeSpentHrs: 6.5 },
// { developer: 'bob', day: 'Tuesday', timeSpentHrs: 8 },
// { developer: 'bob', day: 'Wednesday', timeSpentHrs: 7 },
// { developer: 'bob', day: 'Thursday', timeSpentHrs: 7 },
// ],
// type: 'bar',
// labels: true,
// keys: {
// x: 'day', // it's possible to specify 'x' when category axis
// value: ['developer', 'timeSpentHrs'],
// }
// },
// bindto: '#chart2',
// axis: {
// x: {
// type: 'category'
// }
// }
// });


var chart3 = c3.generate({
data: {
Expand Down

0 comments on commit 6f489e3

Please sign in to comment.