1

I start with rackup --host 0.0.0.0 -p 80, my config.ru file contains the following:

require_relative 'app/config/initializer'

run Manager.freeze.app

# What I need, but does not work.
at_exit do
  Manager.stop_all_services
end

at_exit does not seem to get hit when I stop my docker-console setup. I don't even know if it works for a normal script. Does anyone have an idea how to execute some code when I stop the webserver I started with rackup?

Edit: Removed all non-related docker info, since it was distracting from the original question.

  • This sounds like the wrong way of going about it. At the top level you're using docker-compose which spawns containers including this Ruby one, and you want to use one of these containers to manage the other containers? Use the higher-level tool the manage the lower level tools, not the other way around. – anothermh Apr 24 '20 at 22:47
  • I added the information you requested @anothermh but please keep in mind that my "bad" setup might cause the problem in my case, but this is kind of expected in my learning-project. Making bad decisions to learn more. This "Bad" decision does not change the question for other people who would like to execute some code on exit and have a valid reason. Never the less, thanks for pointing it out. – Dennis van de Hoef - Xiotin Apr 25 '20 at 06:55
  • I didn't ask for any details, but it's good you added more. As for doing things the wrong way and using it as a learning experience, my experience says now is the time to stop doing the wrong thing and switch to something else: you've already learned it's wrong. – anothermh Apr 25 '20 at 06:57

1 Answers1

0

As it turned out at_exit simply works. I think something else in my setup is broken.

Thanks for your time!