-
Notifications
You must be signed in to change notification settings - Fork 16
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
Implement AwesomeSpawn.run_detached #32
Conversation
lib/awesome_spawn.rb
Outdated
|
||
options[[:out, :err]] = ["/dev/null", "w"] unless (options.keys.flatten & [:out, :err]).any? | ||
options[:pgroup] = true unless options.key?(:pggroup) | ||
options[:pggroup_new] = true unless options.key?(:pggroup_new) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there are typos here and in all the docs s/pggroup/pgroup/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommend replacing "/dev/null" with IO::NULL
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like it is new_pgroup
vs pgroup_new
too. thnx
Been hoping for this method to be added! Glad it's coming together |
lib/awesome_spawn.rb
Outdated
@@ -101,6 +101,29 @@ def run!(command, options = {}) | |||
command_result | |||
end | |||
|
|||
# Execute `command` in a detached manner | |||
# by default the :err, and :out are redirected to `/dev/null` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"redirected to the null device".
lib/awesome_spawn.rb
Outdated
def detach(env, command, options) | ||
pid = Kernel.spawn(env, command, options) | ||
Process.detach(pid) | ||
pid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can simplified to Process.detach(pid).pid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
next rev
@kbrock how much work is it to bring this ancient PR over the finish line? |
this spawns a thread but runs in a separate process. It can run in the same or a different
Checked commit kbrock@14f214e with ruby 2.6.3, rubocop 0.69.0, haml-lint 0.28.0, and yamllint |
Don't exactly remember why this was WIP. I fixed to run on a mac. Documentation for Kernel.spawn was a little ambigious in terms of which parameters were allowed in certain environments. I have not tested the windows environment. It spawns off the command line and I am un-WIPing it. |
Hey @bdunne any chance we can get a release that includes this? I haven't looked at what else landed in master but I'd like to use this instead of |
I can take a look. |
I just noticed there aren't specs for this. I can release anyway, but would feel more comfortable using it if we had some specs. |
Released in 1.6.0, but of course I typod it in the commit message / changelog. Fixed the changelog in #71 |
Add ability to detach a command but use all the command line generation goodness of
AwesomeSpawn.run
.This also serves as a best practice to collect all the methods necessary to call spawn.
I noticed that we will probably need a run_in_sub_process / wait_for kind of method.
Was about to run some tests, but wanted to check in first on what I had so far
/cc @Fryguy