/sqlserverwaiter

Waits until SqlServer is started and ready to receive commands

Primary LanguageGo

SQLServer wait

This application waits for an specified time until a Microsoft SQL Server accepts connections. I need it for automatization.

Options

The flag -h provides info about the disponible flags. Running:

sqlserverwait -h

Will show info about the options and default values:

Usage:
  sqlserverwaiter [flags]

Flags:
  -d, --database string    Database name to connect: ex. BikeStores (default "BoIsBo")
      --debug              Show debug info
  -h, --help               help for sqlserverwaiter
      --host string        Database server host (default "localhost")
  -p, --password string    Database user password (default "X1nGuXunG1")
      --port int           Numeric database port (default 1433)
  -t, --timeout duration   Time to wait: 30s, 2m, ... (default 30s)
  -u, --user string        Database user (default "sa")
      --version            version for sqlserverwaiter

If no flag is provided default value is taken

Env vars

Most of the options can be provided with environment vars started with "SQLW_". Ex. the flag "--password" can be provided with the environment variable SQLW_PASSWORD

Examples

Run the command with SQL Server not started. The app tries to connect until timeout is reached.

sqlserver stopped

SQL Server can be started but not accepting connections. Sqlserverwaiter waits until it accepts connections

sqlserver starts