nicosantangelo / sublime-gulp

Run Gulp tasks and use snippets from Sublime Text
https://sublime-gulp.nicosantangelo.com/
MIT License
155 stars 18 forks source link

Can't run two gulps at the same time #71

Closed creativematter closed 7 years ago

creativematter commented 7 years ago

I often have to jump back and forth between a couple of projects so I need to be able to have a gulp watch task running for each project that I'm working on.

I tried opening two projects in Sublime Text, running gulp watch in each using the "Run Arbitrary Task" menu option which works as expected. However, if I go to project 2 and kill the gulp task by using the "Kill all gulp tasks" menu item, it outputs this in project 2's console:

Finishing the following running tasks: $ gulp watch $ gulp watch

This indicates that it's killed both gulp processes which is not want I want. However, it also seems to have gotten confused - it kills the gulp task for project 1 (not indicated in project 1's console), but project 2's gulp task is still running, and responds to changes (and shows them in the console even though it previously indicated that it had killed the tasks).

Even though it still responds, I also can't kill the gulp task from either project 1 or 2 - both just say "Gulp: There are no running tasks". This leaves me with a gulp instance that Sublime thinks is closed and I have to kill it via the command line.

Does this package support multiple projects each with an instance of gulp watch running at the same time?

nicosantangelo commented 7 years ago

Hmm this is a tough one. The way the package "knows" which long running gulp tasks are open is by keeping an in memory array with each pid, when you call Kill all gulp tasks it iterates over it, kills each task, and cleans it. That is hackish to say the least, meaning that if you close and reopen Sublime, or even if Sublime decides to reload its environment, the pids are lost.

I had the idea for killing individual tasks ( #38 ) and to save pids to the .sublime-gulp.cache but I never got around to implement it (yet).

Having said all that, I could check this use case and see if the package can react to it in a better way, so I'll try to reproduce it locally with two of my projects. Just a question, when you say that you open two projects, you mean in two different Sublime windows or adding two folders to the same window?

nicosantangelo commented 7 years ago

@kikandrew I think I found it 🎉 If I'm not mistaken, the fix is surprisingly simple. It should be up in version v5.5.1, please let me know how it goes.

Meanwhile, this issue sparked my interest in killing specific tasks again so I'll try to give it a go

creativematter commented 7 years ago

@NicoSantangelo Awesome, that did fix the bug in regards to closing the wrong one!

So the current flow is that when I go to Kill all gulp tasks in either project, it closes the gulp tasks for both projects. Not perfect, but definitely much better than leaving processes when they shouldn't be.

If you are able to have it kill specific tasks then that would be awesome, but the way it works now is fine really.

Thanks! 😃