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

What is detached mode? #80

Closed
noomorph opened this issue Apr 20, 2017 · 5 comments
Closed

What is detached mode? #80

noomorph opened this issue Apr 20, 2017 · 5 comments

Comments

@noomorph
Copy link

noomorph commented Apr 20, 2017

Saw it mentioned here but nowhere else:

https://github.com/jharding/grunt-exec/blob/master/tasks/exec.js#L14

@noomorph
Copy link
Author

noomorph commented Apr 20, 2017

Or you meant detached from here: https://nodejs.org/api/child_process.html ?

@gwicksted
Copy link
Collaborator

You are correct. Have not updated the docs yet. Needs more testing to cover some edge cases (as discovered in #79) before release since it was a major change switching from exec to spawn.

@noomorph
Copy link
Author

noomorph commented Apr 20, 2017

@gwicksted, thanks. Initially, I've thought about a different scenario, and to be honest, I'm still looking for the appropriate solution for this and I want to share my problem.

Imagine, I've got several 3rd-party CLI tools supporting --watch mode. Usually, it means that whenever I run them, they do a full amount of work and then start watching for individual file changes.

  1. tsc -p path/to/tsconfig.json --watch
  2. webpack --config path/to/webpack.dev.config.js --watch
  3. karma start path/to/karma.conf.js --auto-watch

For me it looks perfectly fine to write accordingly three tasks: exec:ts-watch, exec:webpack-watch, exec:karma-watch, but it looks like that grunt-ts does not support yet some kind of "detachment" from its tasks that I need in my case. Maybe I'm wrong.

I mean that if write:

grunt.registerTask('serve', ['exec:ts-watch', 'exec:webpack-watch', 'exec:karma-watch', 'watch:dev']);

I'll be stuck forever on 'exec:ts-watch'.
Instead, I would like to see some child process creation that will guarantee that after the parent grunt process is finished or killed, we'll also clean up after ourselves and kill all exec:*-watch tasks. Once we created child process , we report that the task has finished its work. Ideally, the exact moment of done() is nice to have under control in some options.afterChildProcessCreatedCallback.

So, I've started some sort of experimenting here: https://github.com/noomorph/grunt-exec/commit/b10a95fdbf7279f08719b47af668ea7e4a547726#diff-f7fa85a898002b4e35a70421dcca8ab4R248

Maybe, you could advise me in which direction it is better to move?

@gwicksted
Copy link
Collaborator

Might be overkill but forever (npm here) gives you the flexibility to do just about anything with background processes. There is also an async task for grunt but that simply allows multiple tasks to be run in parallel and you probably want your terminal back after executing grunt... another option if you're in linux: try using screen (gnu man) -- I haven't tried it with tsc but I assume no compatibility issues. Then you can reattach with screen -r or kill the pid to stop it.

@noomorph
Copy link
Author

Thanks, @gwicksted . Your suggestions do not match my needs but I realized that using grunt-exec in my case is not a right decision. I should be modifying grunt-ts probably.

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

2 participants