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
3018214afb36
Commit
3018214afb36
authored
7 years ago
by
Vincent Hatakeyama
Browse files
Options
Downloads
Patches
Plain Diff
use supprocess.call when not starting several dockers to allow the use of pdb
parent
ac732db1c937
No related branches found
Branches containing commit
Tags
15.3.0
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
+68
-42
68 additions, 42 deletions
docker_dev_start.py
with
68 additions
and
42 deletions
docker_dev_start.py
+
68
−
42
View file @
3018214a
...
...
@@ -214,6 +214,16 @@
else
:
logging
.
info
(
"
Test image found
"
)
# options is only used with subprocess call
options
=
[
'
--name
'
,
project_name
,
'
--rm
'
,
'
--publish
'
,
'
8069:8069
'
,
'
--tty
'
,
'
--interactive
'
,
]
binds
=
[]
arg
=
[
'
start
'
,
...
...
@@ -257,6 +267,8 @@
# auto detect local ip
if
use_host_network
:
local_ip
=
'
127.0.0.1
'
options
.
append
(
'
--network
'
)
options
.
append
(
'
host
'
)
else
:
local_ip
=
None
try
:
...
...
@@ -376,16 +388,18 @@
arg
.
append
(
'
--addons-path
'
)
arg
.
append
(
'
,
'
.
join
(
all_addons_dir
))
# add volumes
odoo_host_config
=
docker_client
.
create_host_config
(
binds
=
binds
,
port_bindings
=
{
8069
:
8069
},
network_mode
=
'
host
'
if
use_host_network
else
'
bridge
'
,
)
logging
.
debug
(
'
Creating odoo container
'
)
odoo
=
docker_client
.
create_container
(
name
=
project_name
,
host_config
=
odoo_host_config
,
image
=
image
,
command
=
arg
,
tty
=
True
)
logging
.
debug
(
'
Starting odoo container
'
)
docker_client
.
start
(
odoo
.
get
(
'
Id
'
))
if
start_postgresql
:
# use docker-py to be able to stop both the database and odoo
# add volumes
odoo_host_config
=
docker_client
.
create_host_config
(
binds
=
binds
,
port_bindings
=
{
8069
:
8069
},
network_mode
=
'
host
'
if
use_host_network
else
'
bridge
'
,
)
logging
.
debug
(
'
Creating odoo container
'
)
odoo
=
docker_client
.
create_container
(
name
=
project_name
,
host_config
=
odoo_host_config
,
image
=
image
,
command
=
arg
,
tty
=
True
)
logging
.
debug
(
'
Starting odoo container
'
)
docker_client
.
start
(
odoo
.
get
(
'
Id
'
))
...
...
@@ -391,19 +405,19 @@
def
signal_handler
(
code
,
frame
):
if
code
==
signal
.
SIGINT
:
logging
.
debug
(
'
You pressed Ctrl+C!
'
)
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
:
logging
.
info
(
'
Stopping postgresql
'
)
docker_client
.
stop
(
pg
.
get
(
'
Id
'
))
logging
.
info
(
'
Removing container postgresql
'
)
docker_client
.
remove_container
(
pg
.
get
(
'
Id
'
))
sys
.
exit
(
0
)
# TODO add a kill of pg when crashing
signal
.
signal
(
signal
.
SIGINT
,
signal_handler
)
logging
.
info
(
'
Press Ctrl+C to quit
'
)
def
signal_handler
(
code
,
frame
):
if
code
==
signal
.
SIGINT
:
logging
.
debug
(
'
You pressed Ctrl+C!
'
)
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
:
logging
.
info
(
'
Stopping postgresql
'
)
docker_client
.
stop
(
pg
.
get
(
'
Id
'
))
logging
.
info
(
'
Removing container postgresql
'
)
docker_client
.
remove_container
(
pg
.
get
(
'
Id
'
))
sys
.
exit
(
0
)
# TODO add a kill of pg when crashing
signal
.
signal
(
signal
.
SIGINT
,
signal_handler
)
logging
.
info
(
'
Press Ctrl+C to quit
'
)
...
...
@@ -409,12 +423,12 @@
# print docker logs of odoo
stream
=
docker_client
.
logs
(
odoo
.
get
(
'
Id
'
),
stream
=
True
,
follow
=
True
)
while
isRunning
(
docker_client
,
odoo
.
get
(
'
Id
'
)):
try
:
for
log
in
stream
:
sys
.
stdout
.
write
(
log
)
except
ConnectionError
:
# If there is no log for some time requests throw some errors
# we ignore them
pass
# print docker logs of odoo
stream
=
docker_client
.
logs
(
odoo
.
get
(
'
Id
'
),
stream
=
True
,
follow
=
True
)
while
isRunning
(
docker_client
,
odoo
.
get
(
'
Id
'
)):
try
:
for
log
in
stream
:
sys
.
stdout
.
write
(
log
)
except
ConnectionError
:
# If there is no log for some time requests throw some errors
# we ignore them
pass
...
...
@@ -420,7 +434,19 @@
# Clean up, just in case
signal_handler
(
signal
.
SIGINT
,
None
)
# TODO add handling of signal to restart odoo
# Clean up, just in case
signal_handler
(
signal
.
SIGINT
,
None
)
# TODO add handling of signal to restart odoo
else
:
# use call to allow usage of pdb
for
bind
in
binds
:
options
.
append
(
'
--volume
'
)
options
.
append
(
bind
)
cmd
=
[
'
docker
'
,
'
run
'
]
cmd
.
extend
(
options
)
cmd
.
append
(
image
)
cmd
.
extend
(
arg
)
logging
.
debug
(
cmd
)
call
(
cmd
)
def
getVolume
(
docker_client
,
data_volume_name
):
"""
Return the volume passed in parameter, creating it if it does not exists
...
...
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