Commit 30b59b1d authored by Matija Čupić's avatar Matija Čupić

Fix special global $0 offenses

parent 73958470
......@@ -16,4 +16,4 @@ Process.wait(foreman_pid)
exit true if success
abort "#{$0} failed"
abort "#{$PROGRAM_NAME} failed"
......@@ -10,7 +10,7 @@ def main
db_pid = spawn('./run', 'db')
grafana_pid = spawn('./run', 'grafana')
abort "#{$0}: could not connect to Grafana at #{host}:#{port}" unless wait_socket(host, port)
abort "#{$PROGRAM_NAME}: could not connect to Grafana at #{host}:#{port}" unless wait_socket(host, port)
create_data_source(host, port, name: 'InfluxDB', database: 'gitlab', isDefault: true)
create_data_source(host, port, name: 'InfluxDB Internal', database: '_internal')
......@@ -48,6 +48,6 @@ def wait_socket(host, port)
false
end
abort "Usage: #{$0}" unless ARGV.empty?
abort "Usage: #{$PROGRAM_NAME}" unless ARGV.empty?
main
......@@ -19,13 +19,13 @@ end
def main(host, port)
foreman_pid = spawn('./run', 'db')
abort "#{$0}: could not connect to InfluxDB at #{host}:#{port}" unless wait_for_socket(host, port)
abort "#{$PROGRAM_NAME}: could not connect to InfluxDB at #{host}:#{port}" unless wait_for_socket(host, port)
IO.popen(%W[influxdb/bin/influx -host #{host} -port #{port}], 'w') do |influx|
influx.puts "CREATE DATABASE #{DATABASE} WITH duration 1d REPLICATION 1;"
end
abort "#{$0}: failed to create InfluxDB database #{DATABASE}" unless $?.success?
abort "#{$PROGRAM_NAME}: failed to create InfluxDB database #{DATABASE}" unless $?.success?
env = {
'INFLUX_HOST' => host.to_s,
......@@ -35,14 +35,14 @@ def main(host, port)
'INFLUX_DATABASE' => DATABASE.to_s
}
unless system(env, *%w[bundle exec rake], chdir: 'influxdb/influxdb-management')
abort "#{$0}: failed to run influxdb-managemant Rake script"
abort "#{$PROGRAM_NAME}: failed to run influxdb-managemant Rake script"
end
ensure
Process.kill('TERM', foreman_pid)
Process.waitpid(foreman_pid)
end
abort "Usage: #{$0} INFLUXDB_HTTP_PORT" if ARGV.count != 1
abort "Usage: #{$PROGRAM_NAME} INFLUXDB_HTTP_PORT" if ARGV.count != 1
port = ARGV.shift
......
......@@ -17,4 +17,4 @@ Process.wait(foreman_pid)
exit true if success
abort "#{$0} failed"
abort "#{$PROGRAM_NAME} failed"
......@@ -3,7 +3,7 @@
# This script implements 'cd foo && exec bar' without the need to invoke
# /bin/sh for the ' && '.
abort "Usage: #{$0} DIRECTORY COMMAND [ARGUMENTS ...]" if ARGV.count < 2
abort "Usage: #{$PROGRAM_NAME} DIRECTORY COMMAND [ARGUMENTS ...]" if ARGV.count < 2
Dir.chdir(ARGV.shift)
exec(*ARGV)
......@@ -14,6 +14,6 @@ def main(symlink, target)
FileUtils.ln_s(target, symlink)
end
abort "Usage: #{$0} SYMLINK TARGET" if ARGV.count != 2
abort "Usage: #{$PROGRAM_NAME} SYMLINK TARGET" if ARGV.count != 2
main(*ARGV)
......@@ -2,7 +2,7 @@
PG_HOST = "#{Dir.pwd}/postgresql".freeze
def main
abort "#{$0}: could not connect to Postgres at #{PG_HOST}" unless pg_ready?
abort "#{$PROGRAM_NAME}: could not connect to Postgres at #{PG_HOST}" unless pg_ready?
exec(*ARGV)
end
......@@ -17,6 +17,6 @@ def pg_ready?
false
end
abort "Usage: #{$0} COMMAND [ARGUMENT...]" if ARGV.empty?
abort "Usage: #{$PROGRAM_NAME} COMMAND [ARGUMENT...]" if ARGV.empty?
main
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment