Guest User

Untitled

a guest
Apr 23rd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. require 'open3'
  2.  
  3. module ShellJob
  4. @queue = :default
  5.  
  6. def self.perform(*args)
  7. puts "$ #{args.join(' ')}"
  8. Open3.popen3(*args) do |stdin, stdout, stderr|
  9. puts stdout.read.inspect
  10. end
  11. end
  12. end
  13.  
  14. ## Queue it up
  15.  
  16. # Resque.enqueue(ShellJob, 'which', 'cat')
  17. ShellJob.perform('which', 'cat')
  18.  
  19. ## Output:
  20.  
  21. # $ which cat
  22. # "/bin/cat\n"
Add Comment
Please, Sign In to add comment