overmind icon indicating copy to clipboard operation
overmind copied to clipboard

Start if not started

Open schonert opened this issue 2 years ago • 3 comments

Is there a way to tame the error when starting overmind while the session is already running?

Command failed with exit code 1: overmind s
overmind: it looks like Overmind is already running. If it's not, remove ./.overmind.sock and try again
system  | Tmux socket name: overmind-web-k7XQbWNx9lLLwrGRuJuFB
system  | Tmux session ID: web
system  | Listening at ./.overmind.sock

schonert avatar Jun 14 '23 09:06 schonert

This is my current solution. wondering if there's a built in

[ ! -S .overmind.sock ] && overmind s || echo 'overmind already running'

schonert avatar Jun 14 '23 10:06 schonert

./.overmind.sock is a Unix socket used by Overmind to receive commands like restart, connect, etc. It's safe to remove it if you're sure that you don't have Overmind running. Otherwise running Overmind won't be able to receive commands.

I've just thought that this would be useful to check if the socket is actually in use rather than it just exists 🤔

DarthSim avatar Jun 14 '23 14:06 DarthSim

FWIW, I put rm -f ".overmind.sock" in my bin/dev so that Overmind starts even after the IDE crashes or was restarted. Here's the whole file:

#!/usr/bin/env sh

# Setup ENV vars from .env.local
if [ -f .env.local ]
then
  while read -r LINE; do
    if [[ $LINE == *'='* ]] && [[ $LINE != '#'* ]]; then
      ENV_VAR="$(echo $LINE | envsubst)"
      eval "declare $ENV_VAR"
    fi
  done < .env.local
fi

# Ensure default port ENV is set
PORT="${PORT:-3000}"
export PORT

# Ensure required dependencies are present, useful when switching branches
bundle check &> /dev/null || bundle install
yarn check &> /dev/null || yarn install

# Try starting Overmind
if command -v overmind &> /dev/null; then
  # Remove dangling socks from overmind
  rm -f ".overmind.sock"
  exec overmind start -f Procfile.dev --no-port "$@"
else # Fallback to Foreman
  exec foreman start -f Procfile.dev --no-port "$@"
fi

goulvench avatar Apr 08 '24 08:04 goulvench