DarthSim / overmind

Process manager for Procfile-based applications and tmux
MIT License
2.82k stars 79 forks source link

Use overmind from a subfolder #129

Open bbugh opened 2 years ago

bbugh commented 2 years ago

Hi! 👋 Thanks for the great tool.

It would be VERY nice to use overmind from a subfolder especially with monorepos. Many tools like gem, bundle, rake, rubocop, etc. allow you to run commands from a subfolder that reference a higher level configuration.

I saw https://github.com/DarthSim/overmind/issues/77 but I'm confused about the answer and wanted to revisit it.

This feature requires a very careful revision of lots of things such as Procfile detection, socket path detection, .env file loading as so on. However, if your goal is only to interact with running Overmind from subfolders, you can add .overmind.env file to desired subfolders with something like OVERMIND_SOCKET="../.overmind.sock". This will tell Overmind to use a socket from the parent folder.

I don't think the request requires all of these things, unless overmind is coded in an unusual way or Go has some issues with subprocesses. The way this usually works with other commands is traversing the parents looking for the file, setting the working directory, and then running. No special handling is usually required.

graph TD
    A([Traverse parent looking for `.overmind.sock`]) -->B{found?}
    B -->|yes| C[change runner working directory to parent]
    C -->D([Run as usual])
    B -->|no| E([Run usual error])

Does this explanation clarify the request and implementation?

Thanks!

DarthSim commented 2 years ago

Hi @bbugh!

Overmind allows specifying the socket path as well as binding its server to TCP. So simple search for .overmind.sock is not enough for this feature to work properly. Also, Overmind can be configured with .env files, this implies searching .env files, and this may lead to unexpected loads of .env files.

Summarizing:

  1. User may or may not have .overmind.sock in the project directory. So this can't be used as a trait of the project directory.
  2. User may or may not have Procfile named exactly as Procfile. So this can't be used as a trait of the project directory, too.
  3. User may or may not have .overmind.env. So this can't be used as a trait of the project directory, too.