shithub: jirafs

Download patch

ref: 84844799a48e02168bd927b0b3c518b248ba0180
parent: 1d43766c7ccd703adf2015aefc18609748b6f5eb
author: Kenny Levinsen <kl@codesealer.com>
date: Mon Jun 6 16:24:51 EDT 2016

Relogin at 5-minute intervals

--- a/main.go
+++ b/main.go
@@ -4,6 +4,7 @@
 	"fmt"
 	"net"
 	"os"
+	"time"
 
 	"github.com/andygrunwald/go-jira"
 	"github.com/howeyc/gopass"
@@ -33,11 +34,21 @@
 	}
 	password = string(pass)
 
-	res, err := jiraClient.Authentication.AcquireSessionCookie(user, password)
-	if err != nil || res == false {
-		fmt.Printf("Could not authenticate to JIRA: %v\n", err)
-		return
+	auth := func() {
+		res, err := jiraClient.Authentication.AcquireSessionCookie(user, password)
+		if err != nil || res == false {
+			fmt.Printf("Could not authenticate to JIRA: %v\n", err)
+			return
+		}
 	}
+	auth()
+
+	go func() {
+		t := time.NewTicker(5 * time.Minute)
+		for range t.C {
+			auth()
+		}
+	}()
 
 	root, err := NewJiraDir("", 0555|qp.DMDIR, "jira", "jira", jiraClient, &JiraView{})
 	if err != nil {