Commit ae2148be authored by Matija Čupić's avatar Matija Čupić

Fix support script offenses

parent 5c7dccae
......@@ -4,9 +4,9 @@ success = true
begin
foreman_pid = spawn('./run', 'geo_db')
[
%W(bundle exec rake geo:db:setup)
%w[bundle exec rake geo:db:setup]
].each do |cmd|
success &&= system({'force' => 'yes', 'BOOTSTRAP' => '1'}, *cmd, chdir: 'gitlab')
success &&= system({ 'force' => 'yes', 'BOOTSTRAP' => '1' }, *cmd, chdir: 'gitlab')
end
ensure
Process.kill('TERM', foreman_pid)
......@@ -16,4 +16,4 @@ Process.wait(foreman_pid)
exit true if success
abort "#$0 failed"
abort "#{$0} 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 "#{$0}: 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,8 +48,6 @@ def wait_socket(host, port)
false
end
if !ARGV.empty?
abort "Usage: #$0"
end
abort "Usage: #{$0}" unless ARGV.empty?
main
#!/usr/bin/env ruby
require 'socket'
HOST = '127.0.0.1'
DATABASE = 'gitlab'
HOST = '127.0.0.1'.freeze
DATABASE = 'gitlab'.freeze
def wait_for_socket(host,port)
def wait_for_socket(host, port)
30.times do
begin
TCPSocket.new(host, port)
......@@ -19,33 +19,30 @@ 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 "#{$0}: 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|
IO.popen(%W[influxdb/bin/influx -host #{host} -port #{port}], 'w') do |influx|
influx.puts "CREATE DATABASE #{DATABASE} WITH duration 1d REPLICATION 1;"
end
if !$?.success?
abort "#$0: failed to create InfluxDB database #{DATABASE}"
end
abort "#{$0}: failed to create InfluxDB database #{DATABASE}" unless $?.success?
env = {
'INFLUX_HOST' => "#{host}",
'INFLUX_PORT' => "#{port}",
'INFLUX_HOST' => host.to_s,
'INFLUX_PORT' => port.to_s,
'INFLUX_USER' => "",
'INFLUX_PASSWORD' => "",
'INFLUX_DATABASE' => "#{DATABASE}",
'INFLUX_DATABASE' => DATABASE.to_s
}
if !system(env, *%W(bundle exec rake), chdir: 'influxdb/influxdb-management')
abort "#$0: failed to run influxdb-managemant Rake script"
unless system(env, *%w[bundle exec rake], chdir: 'influxdb/influxdb-management')
abort "#{$0}: failed to run influxdb-managemant Rake script"
end
ensure
Process.kill('TERM', foreman_pid)
Process.waitpid(foreman_pid)
end
if ARGV.count != 1
abort "Usage: #$0 INFLUXDB_HTTP_PORT"
end
abort "Usage: #{$0} INFLUXDB_HTTP_PORT" if ARGV.count != 1
port = ARGV.shift
......
......@@ -4,10 +4,10 @@ success = true
begin
foreman_pid = spawn('./run', 'db')
[
%W(bundle exec rake db:create),
%W(bundle exec rake dev:setup),
%w[bundle exec rake db:create],
%w[bundle exec rake dev:setup]
].each do |cmd|
success &&= system({'force' => 'yes', 'BOOTSTRAP' => '1'}, *cmd, chdir: 'gitlab')
success &&= system({ 'force' => 'yes', 'BOOTSTRAP' => '1' }, *cmd, chdir: 'gitlab')
end
ensure
Process.kill('TERM', foreman_pid)
......@@ -17,4 +17,4 @@ Process.wait(foreman_pid)
exit true if success
abort "#$0 failed"
abort "#{$0} failed"
......@@ -2,10 +2,10 @@
begin
foreman_pid = spawn('./run', 'db')
system *%W(support/wait-postgresql-ready createdb -h #{Dir.pwd}/postgresql grafana)
system(*%W[support/wait-postgresql-ready createdb -h #{Dir.pwd}/postgresql grafana])
status = $?
ensure
Process.kill('TERM', foreman_pid)
end
exit status.success?
\ No newline at end of file
exit status.success?
......@@ -3,9 +3,7 @@
# This script implements 'cd foo && exec bar' without the need to invoke
# /bin/sh for the ' && '.
if ARGV.count < 2
abort "Usage: #$0 DIRECTORY COMMAND [ARGUMENTS ...]"
end
abort "Usage: #{$0} DIRECTORY COMMAND [ARGUMENTS ...]" if ARGV.count < 2
Dir.chdir(ARGV.shift)
exec *ARGV
exec(*ARGV)
......@@ -2,7 +2,10 @@
#
# Translate SIGTERM to SIGINT to request a 'fast shutdown' from Postgres.
Signal.trap('TERM') { puts "Sending INT to #$pid"; Process.kill('INT', $pid) }
Signal.trap('TERM') do
puts "Sending INT to #{$pid}"
Process.kill('INT', $pid)
end
$pid = spawn(*ARGV)
Process.wait($pid)
......
......@@ -14,8 +14,6 @@ def main(symlink, target)
FileUtils.ln_s(target, symlink)
end
if ARGV.count != 2
abort "Usage: #{$0} SYMLINK TARGET"
end
abort "Usage: #{$0} SYMLINK TARGET" if ARGV.count != 2
main(*ARGV)
#!/usr/bin/env ruby
PG_HOST = "#{Dir.pwd}/postgresql"
PG_HOST = "#{Dir.pwd}/postgresql".freeze
def main
if !pg_ready?
abort "#$0: could not connect to Postgres at #{PG_HOST}"
end
abort "#{$0}: could not connect to Postgres at #{PG_HOST}" unless pg_ready?
exec *ARGV
exec(*ARGV)
end
def pg_ready?
10.times do
if system *%W(psql -h #{PG_HOST} -d template1 -c SELECT\ now()), out: '/dev/null', err: '/dev/null'
if system(*%W[psql -h #{PG_HOST} -d template1 -c SELECT\ now()], out: '/dev/null', err: '/dev/null')
return true
end
sleep 1
......@@ -19,8 +17,6 @@ def pg_ready?
false
end
if ARGV.empty?
abort "Usage: #$0 COMMAND [ARGUMENT...]"
end
abort "Usage: #{$0} 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