Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle run_on_changes once? #901

Open
AlexWayfer opened this issue Feb 2, 2018 · 8 comments
Open

How to handle run_on_changes once? #901

AlexWayfer opened this issue Feb 2, 2018 · 8 comments

Comments

@AlexWayfer
Copy link
Contributor

Hello!

I have the project with git, guard and guard-puma.

guard-puma has run_on_changes (and nothing more), in which it's sending restart command to puma. Puma restarting in about 5 seconds (depends on project and configuration), in the background.

Problem: on $ git checkout another_branch run_on_changes is triggering multiple times: for modfied files, for added file and for removed files. Puma doesn't have time to restart between these triggers.

Question: can I handle run_on_changes one time for any changes? If there are many changes (additionals, removals, etc.) — anyway one time. Maybe with Hash instead of Array of paths, I don't know. Or it's better with all paths (of added files, removed and modified) in one Array (and one method trigger).

Thank you.

@rymai
Copy link
Member

rymai commented Mar 3, 2018

What you can do is pausing Guard (by entering p or pause in PRY) before checkouting a new branch and un-pausing it, then issuing a Puma restart by entering r or reload in PRY.

@AlexWayfer
Copy link
Contributor Author

What you can do is pausing Guard (by entering p or pause in PRY) before checkouting a new branch and un-pausing it, then issuing a Puma restart by entering r or reload in PRY.

  1. Manual actions 🤢
    Guard is invented for automation of manual actions. I can don't use Guard at all, and restart everything with console, but it's inconvenient.
  2. Interactor is disabled in our project for binding.pry in code (via puma).

@bmulholland
Copy link

Is it possible to send guard commands from outside? I'm wondering if it would be possible to add an alias for git checkout that wraps the actual checkout with a guard pause and unpause.

@AlexWayfer
Copy link
Contributor Author

I'm wondering if it would be possible to add an alias for git checkout that wraps the actual checkout with a guard pause and unpause.

For the whole team of developers? Ha-ha. I don't think so.

@bmulholland
Copy link

bmulholland commented Mar 21, 2018

Not sure what you mean? I was thinking about writing my own git alias (in my own zshrc)... something like alias gch = guard pause && git checkout $1 && guard unpause. But to do that, I'd need some guard (un)pause command that would send a command to a running guard instance.

@AlexWayfer
Copy link
Contributor Author

@bmulholland, oh, sorry. I thought you've suggested me a solution for this issue.

You can look at this section of wiki.

@bmulholland
Copy link

bmulholland commented Mar 21, 2018

Oh nice! So then couldn't you use that to solve the problem in this issue? Specifically instead of this:

What you can do is pausing Guard (by entering p or pause in PRY) before checkouting a new branch and un-pausing it, then issuing a Puma restart by entering r or reload in PRY.

You could just do e.g. gch <branch> where gch does kill -USR1 pgrep guard && git checkout $1 && kill -USR2 pgrep guard. (pgrep guard should be in ` but that messes up GitHub's formatting)

@AlexWayfer
Copy link
Contributor Author

You could just do e.g. gch where gch does kill -USR1 \pgrep guard&& git checkout $1 && kill -USR2pgrep guard``.

OK, one more time: I don't want to ask every developer in our team to add some aliases as work-around.

I'm sure that a library like guard (for files watching) should be possible to catch cases with changes of multiple files as one event.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants