summaryrefslogtreecommitdiff
path: root/lib/run.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/run.rb')
-rw-r--r--lib/run.rb53
1 files changed, 34 insertions, 19 deletions
diff --git a/lib/run.rb b/lib/run.rb
index 7e8539ba332..0a2a668bff1 100644
--- a/lib/run.rb
+++ b/lib/run.rb
@@ -1,31 +1,44 @@
def main(argv)
- case argv[0]
+ applications = applications_from(argv)
+ print_url if applications.include?('gitlab-workhorse')
+ foreman_exec(applications)
+end
+
+def applications_from(argv)
+ exec_thin! if argv[0] == 'thin'
+
+ return %w[all] if argv.empty?
+
+ argv.each_with_object([]) do |command, all|
+ all << applications_for(command)
+ end.flatten.uniq
+end
+
+def exec_thin!
+ exec(
+ { 'RAILS_ENV' => 'development' },
+ *%W[bundle exec thin --socket=#{Dir.pwd}/gitlab.socket start],
+ chdir: 'gitlab'
+ )
+end
+
+def applications_for(command)
+ case command
when 'db'
- foreman_exec(%w[redis postgresql openldap influxdb webpack registry minio elasticsearch jaeger])
+ %w[redis postgresql openldap influxdb webpack registry minio elasticsearch jaeger]
when 'geo_db'
- foreman_exec(%w[postgresql-geo])
+ %w[postgresql-geo]
when 'app'
- svcs = %w[gitlab-workhorse nginx grafana sshd gitaly storage-check gitlab-pages praefect]
-
- foreman_exec(svcs + %w[rails-web rails-background-jobs])
+ %w[gitlab-workhorse nginx grafana sshd gitaly storage-check gitlab-pages praefect rails-web rails-background-jobs]
when 'grafana'
- foreman_exec(%w[grafana])
- when 'thin'
- exec(
- { 'RAILS_ENV' => 'development' },
- *%W[bundle exec thin --socket=#{Dir.pwd}/gitlab.socket start],
- chdir: 'gitlab'
- )
+ %w[grafana]
when 'gitaly'
- foreman_exec(%w[gitaly])
+ %w[gitaly]
when 'jobs'
- foreman_exec(%w[rails-background-jobs])
- when nil
- print_url
- foreman_exec(%w[all])
+ %w[rails-background-jobs]
else
puts
- puts "GitLab Development Kit does not recognize this command."
+ puts "GitLab Development Kit does not recognize command '#{command}'."
puts "Make sure you are using the latest version or check available commands with: \`gdk help\` "
puts
exit 1
@@ -34,11 +47,13 @@ end
def foreman_exec(svcs = [], exclude: [])
args = %w[ruby lib/daemonizer.rb foreman start]
+
unless svcs.empty? && exclude.empty?
args << '-m'
svc_string = ['all=0', svcs.map { |svc| svc + '=1' }, exclude.map { |svc| svc + '=0' }].join(',')
args << svc_string
end
+
exec({
'GITLAB_TRACING' => 'opentracing://jaeger?http_endpoint=http%3A%2F%2Flocalhost%3A14268%2Fapi%2Ftraces&sampler=const&sampler_param=1',
'GITLAB_TRACING_URL' => 'http://localhost:16686/search?service={{ service }}&tags=%7B"correlation_id"%3A"{{ correlation_id }}"%7D'