lib: fix ram usage due to bootstrap
bootstrap now exits (0) when all services are up, instead continuously running. This is combined with a simple bash script, which does this job instead. This also adds /bootstrap.sh as docker ENTRYPOINT
This commit is contained in:
		| @ -25,7 +25,10 @@ RUN apt-get update && \ | |||||||
| COPY ./passbook/ /app/passbook | COPY ./passbook/ /app/passbook | ||||||
| COPY ./manage.py /app/ | COPY ./manage.py /app/ | ||||||
| COPY ./docker/uwsgi.ini /app/ | COPY ./docker/uwsgi.ini /app/ | ||||||
|  | COPY ./docker/bootstrap.sh /bootstrap.sh | ||||||
|  |  | ||||||
| WORKDIR /app/ | WORKDIR /app/ | ||||||
|  |  | ||||||
| USER passbook | USER passbook | ||||||
|  |  | ||||||
|  | ENTRYPOINT [ "/bootstrap.sh" ] | ||||||
|  | |||||||
							
								
								
									
										3
									
								
								docker/bootstrap.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										3
									
								
								docker/bootstrap.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,3 @@ | |||||||
|  | #!/bin/bash -ex | ||||||
|  | /app/manage.py bootstrap | ||||||
|  | $@ | ||||||
| @ -1,10 +1,7 @@ | |||||||
| """passbook management command to bootstrap""" | """passbook management command to bootstrap""" | ||||||
| from argparse import REMAINDER | from argparse import REMAINDER | ||||||
| from subprocess import Popen  # nosec |  | ||||||
| from sys import exit as _exit | from sys import exit as _exit | ||||||
| from sys import stderr, stdin, stdout |  | ||||||
| from time import sleep | from time import sleep | ||||||
| from typing import List |  | ||||||
|  |  | ||||||
| from django.core.management.base import BaseCommand | from django.core.management.base import BaseCommand | ||||||
| from django.db import connection | from django.db import connection | ||||||
| @ -53,13 +50,5 @@ class Command(BaseCommand): | |||||||
|         while should_check: |         while should_check: | ||||||
|             should_check = not (self.check_database() and self.check_cache()) |             should_check = not (self.check_database() and self.check_cache()) | ||||||
|             sleep(1) |             sleep(1) | ||||||
|         LOGGER.info("Dependencies are up, starting command...") |         LOGGER.info("Dependencies are up, exiting...") | ||||||
|         commands: List[str] = options.get("command", ["exit", "1"]) |         _exit(0) | ||||||
|         proc = Popen(args=commands, stdout=stdout, stderr=stderr, stdin=stdin)  # nosec |  | ||||||
|         try: |  | ||||||
|             proc.wait() |  | ||||||
|             _exit(proc.returncode) |  | ||||||
|         except KeyboardInterrupt: |  | ||||||
|             LOGGER.info("Killing process") |  | ||||||
|             proc.kill() |  | ||||||
|             _exit(254) |  | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Jens Langhammer
					Jens Langhammer