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

Support ability to terminate previous invocation of command on new event #59

Open
F21 opened this issue Jan 4, 2019 · 6 comments
Open

Comments

@F21
Copy link

F21 commented Jan 4, 2019

It would be nice if there is an option to terminate the previous invocation of the command when the command is still executing and a file changes. This would be extremely useful when the command is a task that takes a while to complete and we do not wish to wait for it to finish and want to invoke the command immediate again.

@ysmood
Copy link

ysmood commented Jan 10, 2019

@F21 Maybe you should give this tool a try: https://github.com/ysmood/gokit

Same for issue #58

@abdullah2993
Copy link

@F21 this can be achieved by using a shell script.
Here is an example:

#!/bin/sh
if [ -f /.pid ]; then
    kill $(cat /.pid)
fi
go install .
server &
echo $! > /.pid

just make sure the .pid file is outside of your watched directory otherwise it will go into an infinite loop

@ysmood
Copy link

ysmood commented Jan 22, 2019

@abdullah2993 That's not enough, you also need to kill all the subprocesses it creates, or you gonna have leaking issue.
Secondly, the shell script is not cross-platform.

@abdullah2993
Copy link

@ysmood with the script you can kill any(all) processes, in the given example we are only creating a server process and we are killing it on restart. I do agree that this is not a cross-platform solution but you can do the same with a .bat file.

@ysmood
Copy link

ysmood commented Jan 22, 2019

@abdullah2993 at least you need to modify your script like this:

kill -$(cat /.pid)

The minus before the dollar sign is the point.

@abdullah2993
Copy link

abdullah2993 commented Jan 22, 2019

@ysmood you are right. should be kill -- -$(cat /.pid)

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