Skip to content

Instantly share code, notes, and snippets.

@letsjump
Last active December 29, 2022 14:48
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 letsjump/e7314cb3771a3d13d3a58118c8647757 to your computer and use it in GitHub Desktop.
Save letsjump/e7314cb3771a3d13d3a58118c8647757 to your computer and use it in GitHub Desktop.
RubyMine start and restart rails server with docker exec

RubyMine start and restart rails server with docker exec

  1. Add a new file stop_rails.sh in the root of your RoR application with this content
#!/bin/sh

rails_pid=$(cat tmp/pids/server.pid)
kill "$rails_pid"
echo "Rails stopped with PID $rails_pid"
  1. Add execution permission for that file chown +x stop_rails.sh

  2. Open RubyMine "Run / Debug Configurations" popup and add a new "shell script"

immagine

  1. Name it "Stop Rails" and choose Execute: Script Text

  2. Paste this script into the Script Text text field: docker exec -it my-rails-container-name ./stop_rails.sh Please change my-rails-container-name with your rails docker container name

  3. Open the existing Rails developmemt configuration, change "docker-compose" mode to "exec"

  4. Into before launch section click on the (+) button and choose "Run another configuration" from the list and select "Stop Rails"

immagine

Now you can restart rails without need to restart its (and its linked) containers in just a couple of seconds, without the need to wait a full container restart. immagine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment