Commit 028ec30e authored by Jacob Vosmaer's avatar Jacob Vosmaer

Rewrite run script in ruby

parent 9f074abd
Pipeline #25495785 passed with stages
in 24 minutes and 22 seconds
def main(argv)
case argv[0]
when 'db'
foreman_exec(%w[redis postgresql openldap influxdb webpack registry minio elasticsearch])
when 'geo_db'
foreman_exec(%w[postgresql-geo])
when 'app'
svcs = %w[gitlab-workhorse nginx grafana sshd gitaly storage-check]
if argv[1] == 'rails5'
foreman_exec(svcs + %w[rails5-web rails5-background-jobs], exclude: %w[rails-web rails-background-jobs])
else
foreman_exec(svcs + %w[rails-web rails-background-jobs], exclude: %w[rails5-web rails5-background-jobs])
end
when 'grafana'
foreman_exec(%w[grafana])
when 'thin'
exec(
{'RAILS_ENV' => 'development'},
*%W[bundle exec thin --socket=#{Dir.pwd}/gitlab.socket start],
chdir: 'gitlab'
)
when 'gitaly'
foreman_exec(%w[gitaly])
when 'rails5'
print_url
foreman_exec(%w[all], exclude: %w[rails-web rails-background-jobs])
else
print_url
foreman_exec(%w[all], exclude: %w[rails5-web rails5-background-jobs])
end
end
def foreman_exec(svcs=[], exclude: [])
args = %w[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(*args)
end
def print_url
printf "
\033[38;5;88m\` \`
:s: :s:
\`oso\` \`oso.
+sss+ +sss+
:sssss: -sssss:
\`ossssso\` \`ossssso\`
+sssssss+ +sssssss+
-ooooooooo-++++++++++++++-ooooooooo-
\033[38;5;208m\`:/\033[38;5;202m+++++++++\033[38;5;88mosssssssssssso\033[38;5;202m+++++++++\033[38;5;208m/:\`
-///\033[38;5;202m+++++++++\033[38;5;88mssssssssssss\033[38;5;202m+++++++++\033[38;5;208m///-
.//////\033[38;5;202m+++++++\033[38;5;88mosssssssssso\033[38;5;202m+++++++\033[38;5;208m//////.
:///////\033[38;5;202m+++++++\033[38;5;88mosssssssso\033[38;5;202m+++++++\033[38;5;208m///////:
.:///////\033[38;5;202m++++++\033[38;5;88mssssssss\033[38;5;202m++++++\033[38;5;208m///////:.\`
\`-://///\033[38;5;202m+++++\033[38;5;88mosssssso\033[38;5;202m+++++\033[38;5;208m/////:-\`
\`-:////\033[38;5;202m++++\033[38;5;88mosssso\033[38;5;202m++++\033[38;5;208m////:-\`
.-:///\033[38;5;202m++\033[38;5;88mosssso\033[38;5;202m++\033[38;5;208m///:-.
\`.://\033[38;5;202m++\033[38;5;88mosso\033[38;5;202m++\033[38;5;208m//:.\`
\`-:/\033[38;5;202m+\033[38;5;88moo\033[38;5;202m+\033[38;5;208m/:-\`
\`-++-\`\033[0m
"
puts
puts
puts "Starting GitLab in #{Dir.pwd} on http://#{ENV['host']}:#{ENV['port']}#{ENV['relative_url_root']}"
puts
puts
end
main(ARGV)
#!/bin/sh #!/bin/sh
print_url() { # TODO rewrite config parsing in lib/run.rb
printf "
\033[38;5;88m\` \`
:s: :s:
\`oso\` \`oso.
+sss+ +sss+
:sssss: -sssss:
\`ossssso\` \`ossssso\`
+sssssss+ +sssssss+
-ooooooooo-++++++++++++++-ooooooooo-
\033[38;5;208m\`:/\033[38;5;202m+++++++++\033[38;5;88mosssssssssssso\033[38;5;202m+++++++++\033[38;5;208m/:\`
-///\033[38;5;202m+++++++++\033[38;5;88mssssssssssss\033[38;5;202m+++++++++\033[38;5;208m///-
.//////\033[38;5;202m+++++++\033[38;5;88mosssssssssso\033[38;5;202m+++++++\033[38;5;208m//////.
:///////\033[38;5;202m+++++++\033[38;5;88mosssssssso\033[38;5;202m+++++++\033[38;5;208m///////:
.:///////\033[38;5;202m++++++\033[38;5;88mssssssss\033[38;5;202m++++++\033[38;5;208m///////:.\`
\`-://///\033[38;5;202m+++++\033[38;5;88mosssssso\033[38;5;202m+++++\033[38;5;208m/////:-\`
\`-:////\033[38;5;202m++++\033[38;5;88mosssso\033[38;5;202m++++\033[38;5;208m////:-\`
.-:///\033[38;5;202m++\033[38;5;88mosssso\033[38;5;202m++\033[38;5;208m///:-.
\`.://\033[38;5;202m++\033[38;5;88mosso\033[38;5;202m++\033[38;5;208m//:.\`
\`-:/\033[38;5;202m+\033[38;5;88moo\033[38;5;202m+\033[38;5;208m/:-\`
\`-++-\`\033[0m
"
echo
echo
echo "Starting GitLab in $(pwd) on http://${host}:${port}${relative_url_root}"
echo
echo
}
foreman_start() {
exec env port="${port}" host="${host}" relative_url_root="${relative_url_root}" foreman start "$@"
}
db() {
foreman_start -m all=0,redis=1,postgresql=1,openldap=1,influxdb=1,webpack=1,registry=1,minio=1,elasticsearch=1
}
geo_db() {
foreman_start -m all=0,postgresql-geo=1
}
app() {
print_url
if [ "$1" = "rails5" ]; then
foreman_start -m all=0,rails-web=0,rails5-web=1,rails-background-jobs=0,rails5-background-jobs=1,gitlab-workhorse=1,nginx=1,grafana=1,sshd=1,gitaly=1,storage-check=1
else
foreman_start -m all=0,rails-web=1,rails5-web=0,rails-background-jobs=1,rails5-background-jobs=0,gitlab-workhorse=1,nginx=1,grafana=1,sshd=1,gitaly=1,storage-check=1
fi
}
grafana() {
foreman_start -m all=0,grafana=1
}
thin() {
exec /usr/bin/env RAILS_ENV=development support/exec-cd gitlab bundle exec thin --socket="$(pwd)"/gitlab.socket start
}
gitaly() {
foreman_start -m all=0,gitaly=1
}
all() {
print_url
if [ "$1" = "rails5" ]; then
foreman_start -m all=1,rails-web=0,rails-background-jobs=0
else
foreman_start -m all=1,rails5-web=0,rails5-background-jobs=0
fi
}
main() { main() {
# Try to read the gitlab-workhorse host:port from the environments # Try to read the gitlab-workhorse host:port from the environments
...@@ -95,32 +22,11 @@ main() { ...@@ -95,32 +22,11 @@ main() {
port="${port:-3000}" port="${port:-3000}"
relative_url_root="${relative_url_root:-/}" relative_url_root="${relative_url_root:-/}"
case "x$1" in export host
xdb) export port
db export relative_url_root
;;
xgeo_db) exec ruby lib/run.rb "$@"
geo_db
;;
xapp)
app "$2"
;;
xgrafana)
grafana
;;
xthin)
thin
;;
xgitaly)
gitaly
;;
xrails5)
all "rails5"
;;
x*)
all
;;
esac
} }
main "$@" 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