Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
c3202d3f
Commit
c3202d3f
authored
Mar 06, 2017
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sessions: start session gc at startup but only after between 10 - 180 seconds
parent
ebdd35d7
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletions
+7
-1
pkg/middleware/session.go
+7
-1
No files found.
pkg/middleware/session.go
View file @
c3202d3f
package
middleware
import
(
"math/rand"
"time"
"github.com/go-macaron/session"
...
...
@@ -8,6 +9,7 @@ import (
_
"github.com/go-macaron/session/mysql"
_
"github.com/go-macaron/session/postgres"
_
"github.com/go-macaron/session/redis"
"github.com/grafana/grafana/pkg/log"
"gopkg.in/macaron.v1"
)
...
...
@@ -22,10 +24,12 @@ var sessionManager *session.Manager
var
sessionOptions
*
session
.
Options
var
startSessionGC
func
()
var
getSessionCount
func
()
int
var
sessionLogger
=
log
.
New
(
"session"
)
func
init
()
{
startSessionGC
=
func
()
{
sessionManager
.
GC
()
sessionLogger
.
Debug
(
"Session GC"
)
time
.
AfterFunc
(
time
.
Duration
(
sessionOptions
.
Gclifetime
)
*
time
.
Second
,
startSessionGC
)
}
getSessionCount
=
func
()
int
{
...
...
@@ -67,7 +71,9 @@ func Sessioner(options *session.Options) macaron.Handler {
panic
(
err
)
}
go
startSessionGC
()
// start GC threads after some random seconds
rndSeconds
:=
10
+
rand
.
Int63n
(
180
)
time
.
AfterFunc
(
time
.
Duration
(
rndSeconds
)
*
time
.
Second
,
startSessionGC
)
return
func
(
ctx
*
Context
)
{
ctx
.
Next
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment