Closed fh-sholodak closed 4 years ago
In recent updates the xpstar.dll no longer appears in the log lines. I've modified it now to this:
do
[[ "${LOGLINE}" == *"SQL Server is now ready for client connections."* ]] && pkill -P $$ tail
done
I tried this approach but found that parsing the log for "SQL Server is now ready for client connections" wasnt a reliable predictor of when SQL Server is actually ready for connections. I've implemented a different approach which repeatedly tries to run the sqlcmd command until it succeeds or gives up after 50 attempts. Still not exactly elegant but at least it is not an arbitrary sleep command that adds unnecessary wait time.
for i in {1..50}; do /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P Yukon900 -d master -i setup.sql if [ $? -eq 0 ] then echo "setup.sql completed" break else echo "not ready yet..." sleep 1 fi done
Thanks for the sample! I was able to eliminate your 90s delay using the following & figured I'd share it.
https://github.com/twright-msft/mssql-node-docker-demo-app/blob/f24cccb955284dadd96cfbe576c7c92c84b08ad6/import-data.sh#L2
Feel free to upvote these 2 if this is useful to you: https://superuser.com/a/449307 https://stackoverflow.com/a/2379904