mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 03:16:10 -06:00 
			
		
		
		
	updated entrypoint script to wait for postgres
This commit is contained in:
		@@ -15,8 +15,42 @@ map_uidgid() {
 | 
			
		||||
    fi
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
wait_for_postgres() {
 | 
			
		||||
	attempt_num=1
 | 
			
		||||
	max_attempts=5
 | 
			
		||||
 | 
			
		||||
	echo "Waiting for PostgreSQL to start..."
 | 
			
		||||
 | 
			
		||||
	host="${PAPERLESS_DBHOST}"
 | 
			
		||||
 | 
			
		||||
	while !</dev/tcp/$host/5432 ;
 | 
			
		||||
	do
 | 
			
		||||
 | 
			
		||||
		if [ $attempt_num -eq $max_attempts ]
 | 
			
		||||
		then
 | 
			
		||||
			echo "Unable to connect to database."
 | 
			
		||||
			exit 1
 | 
			
		||||
		else
 | 
			
		||||
			echo "Attempt $attempt_num failed! Trying again in 5 seconds..."
 | 
			
		||||
 | 
			
		||||
		fi
 | 
			
		||||
 | 
			
		||||
		attempt_num=$(expr "$attempt_num" + 1)
 | 
			
		||||
		sleep 5
 | 
			
		||||
	done
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
migrations() {
 | 
			
		||||
 | 
			
		||||
	if [[ -n "${PAPERLESS_DBHOST}" ]]
 | 
			
		||||
	then
 | 
			
		||||
		wait_for_postgres
 | 
			
		||||
	fi
 | 
			
		||||
 | 
			
		||||
	(
 | 
			
		||||
		# flock is in place to prevent multiple containers from doing migrations
 | 
			
		||||
		# simultaneously. This also ensures that the db is ready when the command
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user