Skip to content

Instantly share code, notes, and snippets.

@thomas-profitt
Created June 8, 2019 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomas-profitt/eeec888a44c4feb39c62aad518176600 to your computer and use it in GitHub Desktop.
Save thomas-profitt/eeec888a44c4feb39c62aad518176600 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
dirs_and_functions = {
"/home/tom/software/twin_engine/lsi_streaming" => {
"start" => -> {
`docker-stopall`
`sudo systemctl start postgresql`
`sudo systemctl start docker`
`docker-stopall`
`docker-compose start`
},
"shell" => -> {
exec "docker-compose exec app bash"
},
"repl" => -> {
exec "docker-compose exec app rails c"
},
"attach" => -> {
exec "docker attach lsi_app"
}
},
"/home/tom/software/twin_engine/red-ball-oxygen-express" => {
"start" => -> {
`sudo systemctl stop postgresql`
`sudo systemctl start docker`
`docker-stopall`
Dir.chdir "/home/tom/software/twin_engine/red-ball-oxygen-api" do
`docker-compose start`
end
Dir.chdir '/home/tom/software/twin_engine/red-ball-oxygen-suite' do
`docker-compose start express web postgres redis`
end
},
"restart" => -> {
Dir.chdir '/home/tom/software/twin_engine/red-ball-oxygen-suite' do
`docker-compose restart express`
end
},
"shell" => -> {
exec "docker exec -it suite_express bash"
},
"repl" => -> {
exec "docker exec -it suite_express rails c"
},
"attach" => -> {
exec "docker attach suite_express"
},
"logs" => -> {
exec "cd /home/tom/software/twin_engine/red-ball-oxygen-suite && docker-compose logs --tail=100 -f express ; cd -"
},
"ps" => -> {
exec "cd /home/tom/software/twin_engine/red-ball-oxygen-suite && docker-compose ps ; cd -"
},
},
"/home/tom/software/twin_engine/red-ball-oxygen-fill-quotas" => {
"start" => -> {
`sudo systemctl stop postgresql`
`sudo systemctl start docker`
`docker-stopall`
Dir.chdir '/home/tom/software/twin_engine/red-ball-oxygen-suite' do
`docker-compose start fill_quotas web postgres redis`
end
},
},
"/home/tom/software/twin_engine/red-ball-oxygen-suite" => {
"start" => -> {
`sudo systemctl stop postgresql`
`sudo systemctl start docker`
`docker-stopall`
`docker-compose start web postgres redis`
},
},
"/home/tom/software/twin_engine/red-ball-oxygen-replenishment" => {
"start" => -> {
`sudo systemctl stop postgresql`
`sudo systemctl start docker`
`docker-stopall`
`docker-compose start`
},
},
"/home/tom/software/twin_engine/red-ball-oxygen-api" => {
"start" => -> {
puts "CONNECT THEE TO THY VPN"
`sudo systemctl stop postgresql`
`sudo systemctl start docker`
`docker-stopall`
`docker-compose start`
},
"restart" => -> {
puts "CONNECT THEE TO THY VPN"
`docker-compose restart app`
},
"shell" => -> {
exec "docker-compose exec app bash"
},
"repl" => -> {
exec "docker-compose exec app jruby -S rails c"
},
"attach" => -> {
exec "docker attach red-ball-oxygen-api-app"
},
"logs" => -> {
exec "docker-compose logs -f --tail=100 app"
},
"ps" => -> {
exec "docker-compose ps"
},
},
"/home/tom/software/twin_engine/red-ball-oxygen-akeneo" => {
"start" => -> {
`sudo systemctl stop postgresql`
`sudo systemctl start docker`
`docker-stopall`
Dir.chdir '/home/tom/software/twin_engine/red-ball-oxygen-suite' do
`docker-compose start akeneo web mysql mongo`
end
},
},
"/home/tom/software/twin_engine/fibrebond-web" => {
"start" => -> {
`sudo systemctl stop postgresql`
`sudo systemctl start docker`
`docker-stopall`
`docker-compose start`
},
},
}
functions = dirs_and_functions[Dir.pwd]
if !functions
puts "Nothing to do; not in a recognized directory"
exit(1)
end
if !ARGV[0]
puts "devdir: running \"start\" for #{Dir.pwd}"
functions["start"].call()
elsif functions[ARGV[0]]
functions[ARGV[0]].call()
else
puts "No function #{ARGV[0]} for dir #{Dir.pwd}"
exit(1)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment