diff options
author | Ash McKenzie <ash@the-rebellion.net> | 2019-07-12 06:25:13 +0300 |
---|---|---|
committer | Ash McKenzie <ash@the-rebellion.net> | 2019-07-18 09:29:53 +0300 |
commit | b8f13a7336d389fa8f0d4fb712c45272776bc4d8 (patch) | |
tree | 1fdb9d6ee2eccaa381659917db73df9a9106a324 | |
parent | 734b2a67103bd318a164a4f765b1cde327c57137 (diff) |
Support `gdk run` with multiple args
-rw-r--r-- | HELP | 1 | ||||
-rw-r--r-- | doc/howto/gdk_commands.md | 27 | ||||
-rw-r--r-- | doc/howto/geo.md | 2 | ||||
-rw-r--r-- | doc/set-up-gdk.md | 10 | ||||
-rw-r--r-- | lib/run.rb | 53 |
5 files changed, 69 insertions, 24 deletions
@@ -3,6 +3,7 @@ gdk run # Start everything gdk run db # Start enough to run tests gdk run geo_db # Start Geo tracking database +gdk run db geo_db # Start enough to run tests, including Geo tracking database gdk run gitaly # Start gitaly (git backend service) gdk run jobs # Start GitLab background jobs gdk run grafana # Start Grafana in a separate port diff --git a/doc/howto/gdk_commands.md b/doc/howto/gdk_commands.md index 943610dde04..e0be0de4c43 100644 --- a/doc/howto/gdk_commands.md +++ b/doc/howto/gdk_commands.md @@ -1,5 +1,28 @@ # GDK commands +## Running + +To start up the GDK with all default enabled services, run: + +```sh +gdk run +``` + +If you'd like to run a specific group of services, you can do so by providing +the service group names as arguments. Multiple arguments are supported: + +### Run just DB services + +```sh +gdk run db +``` + +### Run DB and Geo DB services + +```sh +gdk run db geo_db +``` + ## Update gitlab and gitlab-shell repositories When working on a new feature, always check that your `gitlab` repository is up @@ -8,7 +31,7 @@ to date with the upstream master branch. In order to fetch the latest code, first make sure that `foreman` for postgres is runnning (needed for db migration) and then run: -``` +```sh gdk update ``` @@ -29,6 +52,6 @@ remove an individual file (e.g. `rm Procfile`) and rebuild it by running `make`. If you want to rebuild _all_ configuration files created by the Makefile, run: -``` +```sh gdk reconfigure ``` diff --git a/doc/howto/geo.md b/doc/howto/geo.md index 1ef0f793824..a32c0f4949c 100644 --- a/doc/howto/geo.md +++ b/doc/howto/geo.md @@ -105,7 +105,7 @@ to operate *as* a primary except in tests where the current Geo node has been stubbed. To ensure the tracking database is started, restart GDK. You will need to use -`gdk run`, rather than `gdk run db`, to run the tests. +`gdk run db geo_db` (at a minimum) or `gdk run` to be able to run the tests. ## Copy database encryption key diff --git a/doc/set-up-gdk.md b/doc/set-up-gdk.md index a592e713a73..31ef7c3fffd 100644 --- a/doc/set-up-gdk.md +++ b/doc/set-up-gdk.md @@ -106,13 +106,19 @@ Start GitLab and all required services: gdk run ``` -To start only the databases use: +To start only the database services, use: ```sh gdk run db ``` -To start only the app (assuming the DBs are already running): +To start database services and gitaly, use: + +```sh +gdk run db gitaly +``` + +To start only the app (assuming the database services are already running), use: ```sh gdk run app 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' |