Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Odoo scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
XCG
Odoo scripts
Commits
301be6c56f6c
Commit
301be6c56f6c
authored
7 years ago
by
Vincent Hatakeyama
Browse files
Options
Downloads
Patches
Plain Diff
detect when script is not running anymore
parent
7d227ee3c120
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
docker_dev_start.py
+10
-4
10 additions, 4 deletions
docker_dev_start.py
with
10 additions
and
4 deletions
docker_dev_start.py
+
10
−
4
View file @
301be6c5
...
...
@@ -385,8 +385,9 @@
def
signal_handler
(
code
,
frame
):
if
code
==
signal
.
SIGINT
:
logging
.
debug
(
'
You pressed Ctrl+C!
'
)
logging
.
info
(
'
Stopping odoo
'
)
docker_client
.
stop
(
odoo
.
get
(
'
Id
'
))
if
isRunning
(
docker_client
,
odoo
.
get
(
'
Id
'
)):
logging
.
info
(
'
Stopping odoo
'
)
docker_client
.
stop
(
odoo
.
get
(
'
Id
'
))
logging
.
info
(
'
Removing container odoo
'
)
docker_client
.
remove_container
(
odoo
.
get
(
'
Id
'
))
if
start_postgresql
:
...
...
@@ -401,7 +402,7 @@
# print docker logs of odoo
stream
=
docker_client
.
logs
(
odoo
.
get
(
'
Id
'
),
stream
=
True
,
follow
=
True
)
while
True
:
while
isRunning
(
docker_client
,
odoo
.
get
(
'
Id
'
))
:
try
:
for
log
in
stream
:
sys
.
stdout
.
write
(
log
)
...
...
@@ -411,7 +412,7 @@
pass
# Clean up, just in case
#
signal_handler(signal.SIGINT, None)
signal_handler
(
signal
.
SIGINT
,
None
)
# TODO add handling of signal to restart odoo
def
getVolume
(
docker_client
,
data_volume_name
):
...
...
@@ -425,6 +426,11 @@
logging
.
debug
(
'
Creating volume %s
'
,
data_volume_name
)
return
docker_client
.
create_volume
(
name
=
data_volume_name
)
def
isRunning
(
docker_client
,
container_id
):
"""
Return true if the container is still running
"""
return
len
(
docker_client
.
containers
(
filters
=
{
'
id
'
:
container_id
},
quiet
=
True
))
if
__name__
==
"
__main__
"
:
return_code
=
main
()
if
return_code
:
...
...
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