Sha256: 741ec608cae0a747aa5d060592868b4cc78f59cf4c2d80278cb44487302359df

Contents?: true

Size: 1.01 KB

Versions: 5

Compression:

Stored size: 1.01 KB

Contents

#!/usr/bin/env ruby

Dir.chdir(File.join(File.dirname(__FILE__), '..'))

File.open(File.join(File.dirname(__FILE__), "../../long.out"), 'w+') do |file|
  file.sync = true
  STDOUT.reopen(file)
  STDERR.reopen(file)

  $:.unshift(File.dirname(__FILE__) + "/../lib")

  require 'etc'
  require 'rubygems'
  require 'bundler'

  begin
    Bundler.setup(:default)
  rescue Bundler::BundlerError => e
    $stderr.puts e.message
    $stderr.puts "Run `bundle install` to install missing gems"
    exit e.status_code
  end

  require 'fire_and_forget'

  include FAF::Daemon

  file.write(("="*40)+"\n")
  file.write("PID: #{$$}\n")
  file.write("User: #{Etc.getlogin}\n")
  file.write("UID: #{Process.uid}\n")
  file.write(`ps -xO nice | grep  '^#{$$}'`)
  file.write("\n")
  ENV.keys.sort.each do | k |
    file.write(" #{k}: #{ENV[k].inspect}\n")
  end
  file.write("\n")

  30.times do |i|
    file.write("#{i}\n")
    begin
      set_task_status(i)
    rescue Exception => e
      file.write(e.to_s + "\n")
    end
    sleep(1)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fire_and_forget-0.3.3 examples/long_task
fire_and_forget-0.3.2 examples/long_task
fire_and_forget-0.3.1 examples/long_task
fire_and_forget-0.3.0 examples/long_task
fire_and_forget-0.2.0 examples/long_task