diff options
author | James Healy <james@yob.id.au> | 2016-05-19 14:02:13 +1000 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2016-08-09 11:22:29 -0500 |
commit | 9fcf54edea0370da23e7d84d135ea7a4d47024b9 (patch) | |
tree | 2262cbd961faac4ea3fed335033f96102715f758 /lib/bundler/cli/exec.rb | |
parent | 114d42b4591f18bffac0af1b87f5bc37a41d81e6 (diff) | |
download | bundler-9fcf54edea0370da23e7d84d135ea7a4d47024b9.tar.gz |
Manually set a process title when using load
With bundler 1.11.2, the process name for rake tasks looked like this:
$ bundle exec rake foo:bar
$ ps ux | grep rake
user 1758 62.2 2.4 385816 202032 pts/3 Sl+ 16:16 0:04 ruby /usr/bin/rake foo:bar
On bundler 1.12.0, the process name changed:
$ bundle exec rake foo:bar
$ ps ux | grep rake
user 1758 62.2 2.4 385816 202032 pts/3 Sl+ 16:16 0:04 /usr/bin/rake
The change in behaviour is caused by bundler 1.12 using `load` (instead of `exec`) where
possible, and manually using `$0=` to set the command name. Unfortunately, that also alters
the process title visible with ps, and using Process.setproctitle can help reverse that
Diffstat (limited to 'lib/bundler/cli/exec.rb')
-rw-r--r-- | lib/bundler/cli/exec.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/bundler/cli/exec.rb b/lib/bundler/cli/exec.rb index f0ce450959..b02a610c21 100644 --- a/lib/bundler/cli/exec.rb +++ b/lib/bundler/cli/exec.rb @@ -63,6 +63,7 @@ module Bundler args.pop if args.last.is_a?(Hash) ARGV.replace(args) $0 = file + Process.setproctitle(process_title(file, *args)) ui = Bundler.ui Bundler.ui = nil require "bundler/setup" @@ -78,6 +79,14 @@ module Bundler abort "#{e.class}: #{e.message}\n #{backtrace.join("\n ")}" end + def process_title(file, *args) + if args.empty? + file + else + "#{file} #{args.join(" ")}".strip + end + end + def ruby_shebang?(file) possibilities = [ "#!/usr/bin/env ruby\n", |