#!/bin/bash

logs=$(docker logs $SERVICE 2>&1)
redis1="# oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo"
redis2="Ready to accept connections"
scheduler="Registering birth"
worker1="Worker rq:worker:"
worker2="Listening on "

if ! [[ $logs =~ $redis1 ]]
    then
        echo "Redis server not started" 1>&2
        exit 1
fi

if ! [[ $logs =~ $redis2 ]]
    then
        echo "Redis server not started" 1>&2
        exit 1
fi

if ! [[ $logs =~ $scheduler ]]
    then
        echo "Redis queue scheduler not started" 1>&2
        exit 1
fi

if ! [[ $logs =~ $worker1 ]]
    then
        echo "Redis worker not started" 1>&2
        exit 1
fi

if ! [[ $logs =~ $worker2 ]]
    then
        echo "Redis worker not started" 1>&2
        exit 1
fi