From 6986009de6e4cdd604e42b447395c02d5ce47823 Mon Sep 17 00:00:00 2001
From: Nicolas Pernoud <github@ninico.fr>
Date: Mon, 15 Oct 2018 12:47:19 +0200
Subject: [PATCH] Put updates in containers

---
 entrypoint.sh          | 20 +++++++++++++++++++-
 nominatim-3.1/start.sh |  8 ++++++++
 start.sh               | 24 +-----------------------
 3 files changed, 28 insertions(+), 24 deletions(-)

diff --git a/entrypoint.sh b/entrypoint.sh
index 9ab50ee..dbe9c4f 100755
--- a/entrypoint.sh
+++ b/entrypoint.sh
@@ -9,7 +9,25 @@ fi
 # Start photon if elastic index exists
 if [ -d "/photon/photon_data/elasticsearch" ]; then
 	echo "Starting photon"
-	java -jar photon.jar -host nominatim -port 5432 -database nominatim -user nominatim -password password1234
+	java -jar photon.jar -host nominatim -port 5432 -database nominatim -user nominatim -password password1234 &
+
+	### Start continuous update ###
+
+	while true; do
+		starttime=$(date +%s)
+
+		curl http://localhost:2322/nominatim-update
+
+		# sleep a bit if updates take less than 5 minutes
+		endtime=$(date +%s)
+		elapsed=$((endtime - starttime))
+		if [[ $elapsed -lt 300 ]]; then
+			sleepy=$((300 - $elapsed))
+			echo "Sleeping for ${sleepy}s..."
+			sleep $sleepy
+		fi
+	done
+
 else
 	echo "Could not start photon, the search index could not be found"
 fi
diff --git a/nominatim-3.1/start.sh b/nominatim-3.1/start.sh
index 8120aea..5a11e92 100755
--- a/nominatim-3.1/start.sh
+++ b/nominatim-3.1/start.sh
@@ -1,4 +1,12 @@
 #!/bin/bash
 service postgresql start
 /usr/sbin/apache2ctl -D FOREGROUND
+
+## Set up nominatim updates ###
+
+sudo -u nominatim ./src/build/utils/update.php --init-updates
+sudo -u nominatim ./src/build/utils/update.php --import-osmosis-all &
+
+## Follow log ###
+
 tail -f /var/log/postgresql/postgresql-9.5-main.log
diff --git a/start.sh b/start.sh
index 06993a5..ead7521 100755
--- a/start.sh
+++ b/start.sh
@@ -3,26 +3,4 @@
 ### Start all containers ###
 
 docker-compose down
-docker-compose up -d
-
-## Set up nominatim updates ###
-
-docker exec -it photon-deploy_nominatim_1 sudo -u nominatim ./src/build/utils/update.php --init-updates
-docker exec -it photon-deploy_nominatim_1 sudo -u nominatim ./src/build/utils/update.php --import-osmosis-all &
-
-### Start continuous update ###
-
-while true; do
-	starttime=$(date +%s)
-
-	curl http://localhost:2322/nominatim-update
-
-	# sleep a bit if updates take less than 5 minutes
-	endtime=$(date +%s)
-	elapsed=$((endtime - starttime))
-	if [[ $elapsed -lt 300 ]]; then
-		sleepy=$((300 - $elapsed))
-		echo "Sleeping for ${sleepy}s..."
-		sleep $sleepy
-	fi
-done
+docker-compose up -d
\ No newline at end of file
-- 
GitLab