Skip to content

Commit

Permalink
Add debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Dec 23, 2020
1 parent 64e1e8d commit ea47352
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ RUN [ -e success ] && gradle :examples:build buildDocs && touch success-examples
FROM builder AS test-builder

RUN [ -e success ] && [ -e success-publish ] && [ -e success-examples-docs ]

VOLUME [ "/src/core" ]
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ build:

docker build $(GIT_HEAD_ARG) --target=runner --tag=camptocamp/mapfish_print core
docker build $(GIT_HEAD_ARG) --target=tester --tag=mapfish_print_tester core
docker build $(GIT_HEAD_ARG) --target=watcher --tag=mapfish_print_watcher core

.PHONY: acceptance-tests-up
acceptance-tests-up:
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ The test (part of the build) requires the 'Liberation Sans' font, which can be d

</div>

# Auto-releoad mode

To be able to quickly test modifications in the print you should:
- Copy the file `docker-compose.override.sample.yaml` to `docker-compose.override.yaml`.
- Run `docker compose up -d`,
The print will be available on port `8080` and on code modification will be built and trigger a restart.

# Create new stabilisation branch

- Create a new branch name x.y from master.
Expand Down
8 changes: 8 additions & 0 deletions core/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,12 @@ FROM runner AS tester
COPY jettyRunExtraFiles/mapfish-spring-application-context-override-acceptencetests.xml \
webapps/ROOT/WEB-INF/classes/mapfish-spring-application-context-override.xml

FROM runner AS watcher

RUN apt update && \
apt install --yes python3-pip rsync && \
apt-get clean && \
rm --recursive --force /var/lib/apt/lists/*
RUN python3 -m pip --disable-pip-version-check --no-cache-dir install inotify

FROM runner AS final
55 changes: 55 additions & 0 deletions core/docker/usr/local/tomcat/bin/docker-start-watch
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env python3

import subprocess
from threading import Lock, Timer

import inotify.adapters

started = True
timer = None


def start():
global started, timer
subprocess.check_call(
[
"rsync",
"--delete",
"--recursive",
"/src/core/build/classes/java/main/org/mapfish/print/",
"/usr/local/tomcat/webapps/ROOT/WEB-INF/classes/org/mapfish/print/",
]
)
subprocess.check_call(["catalina.sh", "start"])
started = True
timer = None
print("PYTHON: &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 555")


def main():
global started, timer
subprocess.check_call(["catalina.sh", "start"])

inotify_tree = inotify.adapters.InotifyTree("/src/core/build")

lock = Lock()
for _, type_names, path, filename in inotify_tree.event_gen(yield_nones=False):
if "IN_CLOSE_WRITE" in type_names:
with lock:

if timer is not None:
print("cancel")
timer.cancel()
timer = None

if started:
subprocess.check_call(["catalina.sh", "stop"])
started = False

timer = Timer(1, start)
timer.start()
print("start")


if __name__ == "__main__":
main()
19 changes: 19 additions & 0 deletions docker-compose.override.sample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
version: '2.1'

services:
builder:
image: mapfish_print_builder
volumes:
- ./core:/src/core
command:
- gradle
- --continuous
- :core:classes

print:
image: mapfish_print_watcher
command:
- /usr/local/tomcat/bin/docker-start-watch
volumes_from:
- builder
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ services:
PRINT_YAML_MAX_ALIASES: 200
LOG_LEVEL: DEBUG
JASPER_LOG_LEVEL: DEBUG
CATALINA_OUT: /dev/stdout

tests:
image: mapfish_print_builder
Expand Down

0 comments on commit ea47352

Please sign in to comment.