fire_and_forget 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/bin/fire_forget CHANGED
@@ -21,9 +21,11 @@ options = OpenStruct.new
21
21
  options.socket = FireAndForget::DEFAULT_SOCKET
22
22
  options.gid = Process.egid
23
23
 
24
+
24
25
  OptionParser.new do |opts|
25
26
  opts.on("-s", "--socket SOCKET", "Socket") { |v| options.socket = v }
26
27
  opts.on("-g", "--socket-group GROUPNAME", "Socket owning group") { |v| options.gid = nil; options.group_name = v }
28
+ opts.on("-d", "--debug", "Turn on debugging") { $debug = true }
27
29
  end.parse!
28
30
 
29
31
  raise ArgumentError, "You must specify a socket file using -s" unless options.socket
@@ -59,8 +61,13 @@ server_thread = Thread.new do
59
61
  session.close_read
60
62
 
61
63
  begin
62
- response = FAF::Server.parse(request)
64
+ command, response = FAF::Server.parse(request)
65
+ puts command.debug if $debug
63
66
  rescue => e
67
+ if $debug
68
+ puts e.message
69
+ puts e.backtrace
70
+ end
64
71
  response = "ERROR #{e}"
65
72
  end
66
73
  session.write(response)
@@ -80,6 +87,7 @@ end
80
87
  end
81
88
 
82
89
  puts "Fire&Forget process #{$$} listening on #{options.socket} ..."
90
+ puts "Debug on" if $debug
83
91
 
84
92
  server_thread.join
85
93
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fire_and_forget}
8
- s.version = "0.3.1"
8
+ s.version = "0.3.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Garry Hill"]
12
- s.date = %q{2011-01-20}
12
+ s.date = %q{2011-01-21}
13
13
  s.default_executable = %q{fire_forget}
14
14
  s.email = %q{garry@magnetised.info}
15
15
  s.executables = ["fire_forget"]
@@ -58,6 +58,7 @@ module FireAndForget
58
58
  Process.setpriority(Process::PRIO_PROCESS, 0, niceness) if niceness > 0
59
59
  # change to the UID of the originating thread if necessary
60
60
  Process::UID.change_privilege(task_uid) unless Process.euid == task_uid
61
+ File.umask(022)
61
62
  exec(cmd)
62
63
  end
63
64
  Process.detach(pid) if pid
@@ -66,6 +67,10 @@ module FireAndForget
66
67
  "OK"
67
68
  end
68
69
  end
70
+
71
+ def debug
72
+ "Fire :#{@task.name}: #{cmd}\n"
73
+ end
69
74
  end
70
75
  end
71
76
  end
@@ -42,6 +42,10 @@ module FireAndForget
42
42
  end if call_params
43
43
  params
44
44
  end
45
+
46
+ def debug()
47
+ "#{self.class.name.split("::").last} #{@task_name}\n"
48
+ end
45
49
  end
46
50
 
47
51
  autoload :Fire, "fire_and_forget/command/fire"
@@ -8,7 +8,7 @@ module FireAndForget
8
8
 
9
9
  def self.run(cmd)
10
10
  if Command.allowed?(cmd)
11
- cmd.run
11
+ [cmd, cmd.run]
12
12
  else
13
13
  raise PermissionsError, "'#{cmd.class}' is not an approved command"
14
14
  end
@@ -1,4 +1,4 @@
1
1
 
2
2
  module FireAndForget
3
- VERSION = "0.3.1"
3
+ VERSION = "0.3.2"
4
4
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 1
9
- version: 0.3.1
8
+ - 2
9
+ version: 0.3.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Garry Hill
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-20 00:00:00 +00:00
17
+ date: 2011-01-21 00:00:00 +00:00
18
18
  default_executable: fire_forget
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency