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

Add a Option to kill current exectution when restarting #100

Open
lucsoft opened this issue Feb 1, 2021 · 6 comments
Open

Add a Option to kill current exectution when restarting #100

lucsoft opened this issue Feb 1, 2021 · 6 comments

Comments

@lucsoft
Copy link

lucsoft commented Feb 1, 2021

No description provided.

@Gambero81
Copy link

great feature!

@GregTCLTK
Copy link

Would love to see this feature!

@KrekkieD
Copy link

KrekkieD commented Dec 3, 2021

This package seems quite useless without this feature, or I'm completely missing how to use it. My command runs an express server and a restart will try to start that server again causing port conflicts. I've tried to listen to various process events, but nothing appears to be fired.

In the end I ended up implementing chokidar through a js file.

@connorjclark
Copy link

I worked around this issue by using pkill to terminate the process in the -c command.

"scripts": {
  "watch-server": "chokidar --initial 'src/*.ts' 'src/server/**/*.ts' -c 'pkill -f \"yarn.js run-server\" ; yarn run-server'",
}

Use pgrep -f "..." first to test what search string you should use. This only worked for me because the yarn run-server bit is actually first turned into yarn.js ... by the shell, so the string I use to find the command to kill is slightly different than the chokidar process (which you don't want to terminate).

@lehni
Copy link

lehni commented Mar 17, 2022

@connorjclark this worked for me, but for Yarn 3 I needed to adjust it to accommodate the version number and different extension in the yarn script:

… -c \"pkill -f 'yarn-.*.cjs <script>'; yarn <script>\"

@cameronbraid
Copy link

There is an old PR with this implemented #31

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

7 participants