chore 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/bin/chore-client CHANGED
@@ -12,6 +12,13 @@ opts = Trollop::options do
12
12
 
13
13
  opt :chore, "name of chore", :type => :string
14
14
  opt :action, "action (start, finish, status, fail, etc)", :type => :string
15
+
16
+ opt :do_every, "interval that chore is expected to run in seconds", :type => :integer
17
+ opt :grace_period, "grace_period above and beyond do_every", :type => :integer
18
+ opt :finish_in, "seconds in which a healthy job should finish", :type => :integer
19
+ opt :expire_in, "seconds until chore is automatically removed from the queue", :type => :integer
20
+
21
+ opt :error, "Error message to use in conjunction with 'fail' action", :type => :string
15
22
  end
16
23
 
17
24
  Trollop::die :chore, "chore name required" if !opts[:chore]
@@ -22,4 +29,22 @@ port = opts[:port]
22
29
 
23
30
  Chore.set_server(server, port)
24
31
 
25
- Chore.public_method(opts[:action]).call(opts[:chore])
32
+
33
+ chore = opts[:chore]
34
+ action = opts[:action]
35
+ chore_opts = {}
36
+
37
+ add_if_exists = lambda do |x|
38
+ chore_opts[x] = opts[x] if opts[x]
39
+ end
40
+
41
+ if action == "start"
42
+ add_if_exists.call(:do_every)
43
+ add_if_exists.call(:grace_period)
44
+ add_if_exists.call(:finish_in)
45
+ add_if_exists.call(:expire_in)
46
+ elsif action == "fail"
47
+ add_if_exists.call(:error)
48
+ end
49
+
50
+ Chore.public_method(action).call(chore, chore_opts)
data/bin/chore-status CHANGED
@@ -9,12 +9,13 @@ opts = Trollop::options do
9
9
 
10
10
  opt :host, "host name of chore-server", :default => 'localhost'
11
11
  opt :port, "port of chore-server", :default => Chore::Constants::DEFAULT_CLI_PORT
12
+ opt :refresh, "auto-refresh every 60 seconds"
12
13
  end
13
14
 
14
15
  server = opts[:host]
15
16
  port = opts[:port]
16
17
 
17
- begin
18
+ def get_and_print server, port
18
19
  sock = TCPSocket.open(server,port)
19
20
  sock.puts ".\r\n"
20
21
 
@@ -26,3 +27,15 @@ begin
26
27
  rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT => ex
27
28
  puts "Couldn't connect to chore-server at #{server}:#{port}"
28
29
  end
30
+
31
+ if opts[:refresh]
32
+ while 1
33
+ print "\e[2J\e[f"
34
+ puts "chore-status - last updated #{Time.now}"
35
+ puts
36
+ get_and_print(server,port)
37
+ sleep(60)
38
+ end
39
+ else
40
+ get_and_print(server,port)
41
+ end
data/lib/chore/server.rb CHANGED
@@ -70,9 +70,11 @@ body {font-family:monospace;background-color:#CCCCCC;}
70
70
  .green {color:green;}
71
71
  table, th, td { border: 1px solid black;}
72
72
  </style>
73
+ <meta http-equiv="refresh" content="60">
73
74
  </head>
74
75
  <body>
75
76
  <h1>Chores</h1>
77
+ <p>Last updated #{Time.now}</p>
76
78
  <table>
77
79
  <tr><th>Job</th><th>Status</th><th>Time</th><th>Notes</th></tr>
78
80
  html
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: chore
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.0
5
+ version: 0.2.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Pikimal, LLC
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-06-15 00:00:00 Z
13
+ date: 2012-06-22 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: eventmachine
@@ -56,7 +56,7 @@ dependencies:
56
56
  version: "0"
57
57
  type: :development
58
58
  version_requirements: *id004
59
- description: Monitor chorse
59
+ description: System health tool for everyone
60
60
  email: grant@pikimal.com
61
61
  executables:
62
62
  - chore-server
@@ -101,6 +101,6 @@ rubyforge_project:
101
101
  rubygems_version: 1.8.11
102
102
  signing_key:
103
103
  specification_version: 3
104
- summary: Monitor chores
104
+ summary: Monitor recurring chores
105
105
  test_files: []
106
106