Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tabacco
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai3
tools
tabacco
Commits
d779743e
Commit
d779743e
authored
Aug 01, 2018
by
ale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move debugging code to top-level package
parent
eaa119ca
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
14 deletions
+17
-14
agent.go
agent.go
+6
-6
backup.go
backup.go
+3
-0
debug.go
debug.go
+5
-5
jobs/job.go
jobs/job.go
+1
-1
jobs/scheduler.go
jobs/scheduler.go
+2
-2
No files found.
agent.go
View file @
d779743e
...
...
@@ -44,14 +44,14 @@ func NewAgent(ctx context.Context, configMgr *ConfigManager, ms MetadataStore) (
}
// Close the Agent and all associated resources.
func
(
d
*
Agent
)
Close
()
{
d
.
mgr
.
Close
()
// nolint
d
.
sched
.
Stop
()
func
(
a
*
Agent
)
Close
()
{
a
.
mgr
.
Close
()
// nolint
a
.
sched
.
Stop
()
}
func
(
d
*
Agent
)
startHTTPServer
(
addr
string
)
error
{
//http.Handle("/debug/jobs", d.mgr.StateManager
)
http
.
Handle
(
"/debug/sched"
,
d
.
sched
)
func
(
a
*
Agent
)
startHTTPServer
(
addr
string
)
error
{
http
.
HandleFunc
(
"/debug/jobs"
,
a
.
handleStateManagerDebug
)
http
.
Handle
Func
(
"/debug/sched"
,
a
.
handleSchedulerDebug
)
go
http
.
ListenAndServe
(
addr
,
nil
)
return
nil
}
...
...
backup.go
View file @
d779743e
...
...
@@ -130,4 +130,7 @@ type Manager interface {
RestoreJob
(
context
.
Context
,
FindRequest
,
string
)
(
jobs
.
Job
,
error
)
Restore
(
context
.
Context
,
FindRequest
,
string
)
error
Close
()
error
// Debug interface.
GetStatus
()
([]
jobs
.
Status
,
[]
jobs
.
Status
,
[]
jobs
.
Status
)
}
jobs/
debug.go
→
debug.go
View file @
d779743e
package
jobs
package
tabacco
import
(
"html/template"
...
...
@@ -112,8 +112,8 @@ func init() {
// ServeHTTP implements the job status debug handler, by making the
// stateManager object match the http.Handler interface.
func
(
j
*
StateManager
)
ServeHTTP
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
pending
,
running
,
done
:=
j
.
g
etStatus
()
func
(
a
*
Agent
)
handleStateManagerDebug
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
pending
,
running
,
done
:=
a
.
mgr
.
G
etStatus
()
w
.
Header
()
.
Set
(
"Content-Type"
,
"text/html"
)
_
=
debugTpl
.
Lookup
(
"state_manager_debug_page"
)
.
Execute
(
w
,
map
[
string
]
interface
{}{
...
...
@@ -128,9 +128,9 @@ func (j *StateManager) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// ServeHTTP implements the job status debug handler, by making the
// stateManager object match the http.Handler interface.
func
(
s
*
Scheduler
)
ServeHTTP
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
func
(
a
*
Agent
)
handleSchedulerDebug
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
w
.
Header
()
.
Set
(
"Content-Type"
,
"text/html"
)
_
=
debugTpl
.
Lookup
(
"scheduler_debug_page"
)
.
Execute
(
w
,
map
[
string
]
interface
{}{
"Schedule"
:
s
.
g
etStatus
(),
"Schedule"
:
a
.
sched
.
G
etStatus
(),
})
}
jobs/job.go
View file @
d779743e
...
...
@@ -340,7 +340,7 @@ func jobStatusListToSlice(l *list.List) []Status {
// GetStatus returns three lists of Status objects, representing
// respectively pending jobs (waiting to run), running jobs, and
// completed jobs (ordered by decreasing timestamp).
func
(
m
*
StateManager
)
g
etStatus
()
([]
Status
,
[]
Status
,
[]
Status
)
{
func
(
m
*
StateManager
)
G
etStatus
()
([]
Status
,
[]
Status
,
[]
Status
)
{
m
.
mx
.
Lock
()
defer
m
.
mx
.
Unlock
()
...
...
jobs/scheduler.go
View file @
d779743e
...
...
@@ -213,8 +213,8 @@ func cronJobStatusListOrderByName(list []CronJobStatus) *cronJobStatusList {
}
}
//
g
etStatus returns the current status of the scheduled jobs.
func
(
s
*
Scheduler
)
g
etStatus
()
[]
CronJobStatus
{
//
G
etStatus returns the current status of the scheduled jobs.
func
(
s
*
Scheduler
)
G
etStatus
()
[]
CronJobStatus
{
s
.
mx
.
Lock
()
defer
s
.
mx
.
Unlock
()
if
s
.
cur
==
nil
{
...
...
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