Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
flamenco-worker-python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blender
flamenco-worker-python
Commits
7b0b641d
Commit
7b0b641d
authored
7 years ago
by
Sybren A. Stüvel
Browse files
Options
Downloads
Patches
Plain Diff
Added `--single` CLI option to shut down the Worker after one task.
parent
9390483d
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
CHANGELOG.md
+1
-0
1 addition, 0 deletions
CHANGELOG.md
flamenco_worker/cli.py
+6
-0
6 additions, 0 deletions
flamenco_worker/cli.py
flamenco_worker/runner.py
+1
-0
1 addition, 0 deletions
flamenco_worker/runner.py
flamenco_worker/worker.py
+7
-1
7 additions, 1 deletion
flamenco_worker/worker.py
with
15 additions
and
1 deletion
CHANGELOG.md
+
1
−
0
View file @
7b0b641d
...
...
@@ -15,6 +15,7 @@ changed functionality, fixed bugs).
-
Worker can be told to shut down by the Manager. The environment (for example systemd
on Linux) is responsible for restarting Flamenco Worker after such a shutdown.
-
Added
`--version`
CLI option to show the version of Flamenco Worker and quit.
-
Added
`--single`
or
`-1`
CLI option to shut down the Worker after executing a single task.
## Version 2.0.8 (released 2017-09-07)
...
...
This diff is collapsed.
Click to expand it.
flamenco_worker/cli.py
+
6
−
0
View file @
7b0b641d
...
...
@@ -31,6 +31,8 @@ def main():
help
=
"
Starts up in testing mode, in which only a handful of
"
"
test-specific task types are accepted. This overrides the task_types
"
"
in the configuration file.
"
)
parser
.
add_argument
(
'
-1
'
,
'
--single
'
,
action
=
'
store_true
'
,
help
=
"
Runs a single tasks, then exits.
"
)
args
=
parser
.
parse_args
()
if
args
.
version
:
...
...
@@ -55,6 +57,9 @@ def main():
confparser
.
erase
(
'
worker_id
'
)
confparser
.
erase
(
'
worker_secret
'
)
if
args
.
single
:
log
.
info
(
'
Running in single-task mode, will stop after performing one task.
'
)
# Find the Manager using UPnP/SSDP if we have no manager_url.
if
not
confparser
.
value
(
'
manager_url
'
):
from
.
import
ssdp_discover
...
...
@@ -108,6 +113,7 @@ def main():
push_log_max_entries
=
confparser
.
value
(
'
push_log_max_entries
'
,
int
),
push_act_max_interval
=
confparser
.
interval_secs
(
'
push_act_max_interval_seconds
'
),
initial_state
=
'
testing
'
if
args
.
test
else
'
awake
'
,
run_single_task
=
args
.
single
,
)
mir
=
may_i_run
.
MayIRun
(
...
...
This diff is collapsed.
Click to expand it.
flamenco_worker/runner.py
+
1
−
0
View file @
7b0b641d
...
...
@@ -62,6 +62,7 @@ class TaskRunner:
return
False
self
.
_log
.
info
(
'
Task %s completed succesfully.
'
,
task_id
)
self
.
current_command
=
None
return
True
async
def
abort_current_task
(
self
):
...
...
This diff is collapsed.
Click to expand it.
flamenco_worker/worker.py
+
7
−
1
View file @
7b0b641d
...
...
@@ -56,6 +56,7 @@ class FlamencoWorker:
# Indicates the state in which the Worker should start
initial_state
=
attr
.
ib
(
validator
=
attr
.
validators
.
instance_of
(
str
),
default
=
'
awake
'
)
run_single_task
=
attr
.
ib
(
validator
=
attr
.
validators
.
instance_of
(
bool
),
default
=
False
)
# When Manager tells us we may no longer run our current task, this is set to True.
# As a result, the cancelled state isn't pushed to Manager any more. It is reset
...
...
@@ -433,6 +434,11 @@ class FlamencoWorker:
except
Exception
:
self
.
_log
.
exception
(
'
While notifying manager of failure, another error happened.
'
)
finally
:
if
self
.
run_single_task
:
self
.
_log
.
info
(
'
Running in single-task mode, exiting.
'
)
self
.
go_to_state_shutdown
()
return
if
self
.
state
==
WorkerState
.
AWAKE
:
# Schedule a new task run unless shutting down or sleeping; after a little delay to
# not hammer the world when we're in some infinite failure loop.
...
...
@@ -637,7 +643,7 @@ class FlamencoWorker:
using systemd on Linux with Restart=always will do this.
"""
self
.
_log
.
info
(
'
Shutting down by request of the
Flamenco Manager
'
)
self
.
_log
.
info
(
'
Shutting down by request of the
Manager or due to single-task mode
'
)
self
.
state
=
WorkerState
.
SHUTTING_DOWN
# Don't bother acknowledging this status, as we'll push an "offline" status anyway.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment