Service restart action and connection to influxDB

Ubuntu 16.04, chef-client version 12.21.12
My receipt

apt_package 'influxdb' do
  version '1.3.5-1'
end

template '/etc/influxdb/influxdb.conf' do
  source 'config_influxdb.erb'
  owner 'root'
  group 'root'
  mode '0644'
  notifies :restart, "service[influxdb]", :immediately
end

bash 'create admin user' do
  code <<-EOH
  influx --execute "CREATE USER "admin" WITH PASSWORD 'mysuperpass' WITH ALL PRIVILEGES"
  echo "influxdb admin user created" > /opt/chef/run_once_tag
  EOH
  not_if { ::File.exists?("/opt/chef/run_once_tag") }
end

I get error

INFO: template[/etc/influxdb/influxdb.conf] sending restart action to service[influxdb] (immediate)
service[influxdb] action restart[2017-09-20T14:24:45+00:00] INFO: Processing service[influxdb] action restart (influxdata::default line 76)
INFO: service[influxdb] restarted
[execute] Failed to connect to http://localhost:8086: Get http://localhost:8086/ping: dial tcp [::1]:8086: getsockopt: connection refused
Please check your connection settings and ensure ‘influxd’ is running.

So it looks like influxdb service is restarted before running bash resource with CREATE USER but it doesn’t really.
If I run chef-client second time service is already started and bash resource runs successfully.
I tried to add

execute “systemctl start influxdb” do
end

before bash resource but it doesn’t fix the problem.

I do not know influxdb, but isn’t it possible that the influxdb service gets restarted and after that it takes some time to start the influxd ?
According to the error it is missing the influxd

if service restart is creating an issue, try retries and retry_delay options with the service configuration.
Also, it seems to me that service takes time to purely come up and bash triggers next command before that so it is unable to find the service that time.
one hack you can directly use sleep 10 to pause the recipe for 10 seconds.
Or
you can use a ruby_block with shell command nc -z localhost:8086 and loop it until it succeeds.