Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tristan Cavelier
slapos.toolbox
Commits
8a51a7c9
Commit
8a51a7c9
authored
Feb 10, 2015
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
equeue: prevent to run import script if takeover-triggered file exists.
parent
d0b201f2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
slapos/equeue/__init__.py
slapos/equeue/__init__.py
+13
-0
No files found.
slapos/equeue/__init__.py
View file @
8a51a7c9
...
...
@@ -87,6 +87,8 @@ class EqueueServer(SocketServer.ThreadingUnixStreamServer):
# Equeue Specific elements
self
.
setLogger
(
self
.
options
.
logfile
[
0
],
self
.
options
.
loglevel
[
0
])
self
.
setDB
(
self
.
options
.
database
[
0
])
if
getattr
(
self
.
options
,
'takeover_triggered_file_path'
,
None
):
self
.
takeover_triggered_file_path
=
self
.
options
.
takeover_triggered_file_path
[
0
]
# Lock to only have one command running at the time
self
.
thread_lock
=
threading
.
Lock
()
# Lockfile is used by other commands to know if an import is ongoing.
...
...
@@ -106,7 +108,16 @@ class EqueueServer(SocketServer.ThreadingUnixStreamServer):
def
setDB
(
self
,
database
):
self
.
db
=
gdbm
.
open
(
database
,
'cs'
,
0700
)
def
_hasTakeoverBeenTriggered
(
self
):
if
hasattr
(
self
,
'takeover_triggered_file_path'
)
and
\
os
.
path
.
exists
(
self
.
takeover_triggered_file_path
):
return
True
return
False
def
_runCommandIfNeeded
(
self
,
command
,
timestamp
):
if
self
.
_hasTakeoverBeenTriggered
():
self
.
logger
.
info
(
'Takeover has been triggered, preventing to run import script.'
)
return
with
self
.
thread_lock
as
thread_lock
,
self
.
lockfile
as
lockfile
:
cmd_list
=
command
.
split
(
'
\
0
'
)
cmd_readable
=
' '
.
join
(
cmd_list
)
...
...
@@ -191,6 +202,8 @@ def main():
dest
=
'timeout'
,
type
=
int
,
default
=
3
)
parser
.
add_argument
(
'--lockfile'
,
help
=
"Path to the lock file created when a command is run"
)
parser
.
add_argument
(
'--takeover-triggered-file-path'
,
nargs
=
1
,
required
=
False
,
help
=
"Path to the file created by takeover script to state that it has been triggered."
)
parser
.
add_argument
(
'socket'
,
help
=
"Path to the unix socket"
)
args
=
parser
.
parse_args
()
...
...
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