Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
ai3
tools
tabacco
Commits
29e057fa
Commit
29e057fa
authored
Jun 14, 2019
by
ale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a way to trigger immediate backups
Send SIGUSR1 to the agent binary.
parent
6f7f5cb2
Pipeline
#3435
passed with stages
in 1 minute and 55 seconds
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
0 deletions
+35
-0
README.md
README.md
+4
-0
agent.go
agent.go
+5
-0
cmd/tabacco/agent.go
cmd/tabacco/agent.go
+11
-0
jobs/scheduler.go
jobs/scheduler.go
+15
-0
No files found.
README.md
View file @
29e057fa
...
...
@@ -252,6 +252,10 @@ and this dataset source:
- name: db2
```
## Runtime signals
The agent will reload its configuration on SIGHUP, and it will
immediately trigger all backup jobs upon receiving SIGUSR1.
# TODO
...
...
agent.go
View file @
29e057fa
...
...
@@ -95,3 +95,8 @@ func makeSchedule(ctx context.Context, m Manager, sourceSpecs []SourceSpec, host
return
sched
,
merr
.
OrNil
()
}
// RunNow starts all jobs right now, regardless of their schedule.
func
(
a
*
Agent
)
RunNow
()
{
a
.
sched
.
RunNow
()
}
cmd/tabacco/agent.go
View file @
29e057fa
...
...
@@ -72,12 +72,23 @@ func (c *agentCommand) Execute(ctx context.Context, f *flag.FlagSet, args ...int
return
subcommands
.
ExitFailure
}
// Build the Agent, and hook SIGUSR1 so that it triggers all
// the backup jobs immediately (useful for emergencies or
// debugging purposes).
agent
,
err
:=
tabacco
.
NewAgent
(
ctx
,
configMgr
,
store
)
if
err
!=
nil
{
log
.
Printf
(
"error: %v"
,
err
)
return
subcommands
.
ExitFailure
}
defer
agent
.
Close
()
// nolint
usr1Ch
:=
make
(
chan
os
.
Signal
,
1
)
go
func
()
{
for
range
usr1Ch
{
log
.
Printf
(
"SIGUSR1 received, starting all jobs immediately"
)
agent
.
RunNow
()
}
}()
signal
.
Notify
(
usr1Ch
,
syscall
.
SIGUSR1
)
log
.
Printf
(
"backup agent started"
)
...
...
jobs/scheduler.go
View file @
29e057fa
...
...
@@ -194,6 +194,21 @@ func (s *Scheduler) Stop() {
close
(
s
.
notifyCh
)
}
// RunNow starts all jobs right now, regardless of their schedule.
func
(
s
*
Scheduler
)
RunNow
()
{
s
.
mx
.
Lock
()
defer
s
.
mx
.
Unlock
()
if
s
.
cur
==
nil
{
return
}
for
_
,
entry
:=
range
s
.
cur
.
c
.
Entries
()
{
go
func
(
entry
*
cron
.
Entry
)
{
entry
.
Job
.
Run
()
}(
entry
)
}
}
// CronJobStatus represents the status of a job, either scheduled,
// running, or terminated in the past.
type
CronJobStatus
struct
{
...
...
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