dvdplm-taskr 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,50 @@
1
+ === In Progress...
2
+
3
+ * Log entries in task view can now be filtered by date. By default only entries
4
+ from the last 24 hours are shown.
5
+ * Added experimental 'dont_wait' parameter to the Taskr4Rails action that
6
+ forces the remote code to be forked so that it does not hold up the entire
7
+ server. Currently this will only work if the remote Rails server is running
8
+ on Mongrel.
9
+
10
+ === 0.3.0 :: 2008-06-19
11
+
12
+ * Added "Run Now" function allowing a task to be immediately triggered.
13
+ * The Rest action can now take the 'params' parameter as a CGI string
14
+ (e.g. foo=bar&blah=hello&taskr=awesome). The string does not have
15
+ to be properly URI-encoded, since the algorithm for parsing it simply
16
+ splits it based on & and = symbols.
17
+ * Changed Scheduler gem from the old OpenWFE to the new Rufus.
18
+ * Task executions are now logged to the new log_entries table. These
19
+ log entries are viewable under the task detail page.
20
+ * Exceptions raised when a task is run manually are now handled gracefully
21
+ (or rather, silently, since they should be logged by the action).
22
+ * Blank parameter values are now correctly stored as NULL rather than 0.
23
+
24
+ === 0.2.1 :: 2008-02-28
25
+
26
+ * Updated for compatibility with picnic 0.6.1.
27
+
28
+ === 0.2.0 :: 2008-01-03
29
+
30
+ * Added Taskr4rails action and accompanying Rails plugin for
31
+ executing code on a remote Rails server. See
32
+ http://code.google.com/p/ruby-taskr/wiki/Taskr4rails for
33
+ details.
34
+ * The Howlr action now takes an optional content_type parameter
35
+ to allow for sending out HTML-formatted messages.
36
+ * Better error reporting for Restr-based actions. The remote server's
37
+ response body is now included in Taskr's error report and the
38
+ remote output is printed to the log more cleanly.
39
+ * Change to REST API: the 'action(s)' parameter is now a bit looser.
40
+ You can use 'action' or 'actions' interchangeably, whether you're
41
+ scheduling multiple actions or just one.
42
+ * Fixed some routing problems in the HTML views.
43
+ * The ActiveResource and PHP examples have been updated with
44
+ some more illustrative code and better explanations.
45
+ * Misc bugs fixed while writing extensive documentation. See
46
+ wiki pages at http://code.google.com/p/ruby-taskr/w/list.
47
+
48
+ === 0.1.0 :: 2007-12-21
49
+
50
+ * First public release.
@@ -0,0 +1,34 @@
1
+ CHANGELOG.txt
2
+ GPLv3-LICENSE.txt
3
+ History.txt
4
+ Manifest.txt
5
+ README.txt
6
+ Rakefile
7
+ bin/taskr
8
+ bin/taskr-ctl
9
+ config.example.yml
10
+ examples/active_resource_client_example.rb
11
+ examples/php_client_example.php
12
+ lib/public/prototype.js
13
+ lib/public/taskr.css
14
+ lib/taskr.rb
15
+ lib/taskr/actions.rb
16
+ lib/taskr/controllers.rb
17
+ lib/taskr/environment.rb
18
+ lib/taskr/helpers.rb
19
+ lib/taskr/models.rb
20
+ lib/taskr/version.rb
21
+ lib/taskr/views.rb
22
+ setup.rb
23
+ taskr4rails/LICENSE.txt
24
+ taskr4rails/README
25
+ taskr4rails/Rakefile
26
+ taskr4rails/init.rb
27
+ taskr4rails/install.rb
28
+ taskr4rails/lib/taskr4rails_controller.rb
29
+ taskr4rails/tasks/taskr4rails_tasks.rake
30
+ taskr4rails/test/taskr4rails_test.rb
31
+ taskr4rails/uninstall.rb
32
+ test.rb
33
+ test/taskr_test.rb
34
+ test/test_helper.rb
@@ -0,0 +1,27 @@
1
+ = Taskr
2
+
3
+ Taskr is a stand-alone HTTP daemon, providing a cron-like networked scheduling
4
+ service. Tasks are created and managed via a REST calls over HTTP, allowing
5
+ other REST-aware services to schedule and manage jobs.
6
+
7
+
8
+ Please see Taskr's Google Code site for further information:
9
+
10
+ http://code.google.com/p/ruby-taskr/
11
+
12
+
13
+
14
+ == LICENSE
15
+
16
+ This program is free software: you can redistribute it and/or modify
17
+ it under the terms of the GNU General Public License as published by
18
+ the Free Software Foundation, either version 3 of the License, or
19
+ (at your option) any later version.
20
+
21
+ This program is distributed in the hope that it will be useful,
22
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
23
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
+ GNU General Public License for more details.
25
+
26
+ You should have received a copy of the GNU General Public License
27
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -0,0 +1,85 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/clean'
4
+ require 'rake/testtask'
5
+ require 'rake/packagetask'
6
+ require 'rake/gempackagetask'
7
+ require 'rake/rdoctask'
8
+ require 'rake/contrib/rubyforgepublisher'
9
+ require 'fileutils'
10
+ require 'hoe'
11
+ include FileUtils
12
+ require File.join(File.dirname(__FILE__), 'lib', 'taskr', 'version')
13
+
14
+ AUTHOR = ["Matt Zukowski", "David Palm"] # can also be an array of Authors
15
+ EMAIL = ["matt at roughest dot net", "dvd plm on googles free email service"]
16
+ DESCRIPTION = "cron-like scheduler service with a RESTful interface"
17
+ GEM_NAME = "taskr" # what ppl will type to install your gem
18
+ RUBYFORGE_PROJECT = "taskr" # The unix name for your project
19
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
20
+
21
+
22
+ NAME = "taskr"
23
+ REV = nil
24
+ VERS = ENV['VERSION'] || (Taskr::VERSION::STRING + (REV ? ".#{REV}" : ""))
25
+ CLEAN.include ['**/.*.sw?', '*.gem', '.config']
26
+ RDOC_OPTS = ['--quiet', '--title', "taskr documentation",
27
+ "--opname", "index.html",
28
+ "--line-numbers",
29
+ "--main", "README",
30
+ "--inline-source"]
31
+
32
+ class Hoe
33
+ def extra_deps
34
+ @extra_deps.reject { |x| Array(x).first == 'hoe' }
35
+ end
36
+ end
37
+
38
+ # Generate all the Rake tasks
39
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
40
+ hoe = Hoe.new(GEM_NAME, VERS) do |p|
41
+ p.author = AUTHOR
42
+ p.description = DESCRIPTION
43
+ p.email = EMAIL
44
+ p.summary = DESCRIPTION
45
+ p.url = HOMEPATH
46
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
47
+ p.test_globs = ["test/**/*_test.rb"]
48
+ p.clean_globs = CLEAN #An array of file patterns to delete on clean.
49
+
50
+ # == Optional
51
+ #p.changes - A description of the release's latest changes.
52
+ #p.extra_deps - An array of rubygem dependencies.
53
+ #p.spec_extras - A hash of extra values to set in the gemspec.
54
+
55
+ p.extra_deps = [
56
+ ['picnic', '~> 0.6.4'],
57
+ ['reststop', '~> 0.3.0'],
58
+ ['restr', '~> 0.4.0'],
59
+ ['rufus-scheduler', '~> 1.0.7']
60
+ ]
61
+ p.spec_extras = {:executables => ['taskr', 'taskr-ctl']}
62
+ end
63
+
64
+ desc "Generate gemspec"
65
+ task :gemspec do |x|
66
+ # Check the manifest before generating the gemspec
67
+ manifest = %x[rake check_manifest]
68
+ manifest.gsub!(/\(in .{1,}\)\n/, "")
69
+
70
+ unless manifest.empty?
71
+ print "\n", "#"*68, "\n"
72
+ print <<-EOS
73
+ Manifest.txt is not up-to-date. Please review the changes below.
74
+ If the changes are correct, run 'rake check_manifest | patch'
75
+ and then run this command again.
76
+ EOS
77
+ print "#"*68, "\n\n"
78
+ puts manifest
79
+ else
80
+ gemspec = %x[rake debug_gem]
81
+ gemspec.gsub!(/\(in .{1,}\)\n/, "")
82
+ File.open("#{GEM_NAME}.gemspec",'w'){|f| f<<gemspec}
83
+ # %x[rake debug_gem > #{GEM_NAME}.gemspec]
84
+ end
85
+ end
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # ---------------------------------------------------------------------
4
+ # This file is part of Taskr (http://ruby-taskr.googlecode.com/).
5
+ #
6
+ # Taskr is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # Taskr is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with Taskr. If not, see <http://www.gnu.org/licenses/>.
18
+ # ---------------------------------------------------------------------
19
+
20
+ if File.exists?(picnic = File.expand_path(File.dirname(File.expand_path(__FILE__))+'/../vendor/picnic/lib'))
21
+ $: << picnic
22
+ elsif File.exists?(picnic = File.expand_path(File.dirname(File.expand_path(__FILE__))+'/../../picnic/lib'))
23
+ $: << picnic
24
+ else
25
+ require 'rubygems'
26
+ end
27
+
28
+ require 'picnic/cli'
29
+
30
+ cli = Picnic::Cli.new(
31
+ 'taskr',
32
+ :app_path => File.expand_path(File.dirname(File.expand_path(__FILE__)))
33
+ )
34
+
35
+ cli.handle_cli_input
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # ---------------------------------------------------------------------
4
+ # This file is part of Taskr (http://ruby-taskr.googlecode.com/).
5
+ #
6
+ # Taskr is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later verTaskr
10
+ #
11
+ # Taskr is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with Taskr. If not, see <http://www.gnu.org/licenses/>.
18
+ # ---------------------------------------------------------------------
19
+
20
+ if File.exists?(picnic = File.expand_path(File.dirname(File.expand_path(__FILE__))+'/../vendor/picnic/lib'))
21
+ $: << picnic
22
+ elsif File.exists?(picnic = File.expand_path(File.dirname(File.expand_path(__FILE__))+'/../../picnic/lib'))
23
+ $: << picnic
24
+ else
25
+ require 'rubygems'
26
+ end
27
+
28
+ require 'picnic/service_control'
29
+
30
+ ctl = Picnic::ServiceControl.new('taskr')
31
+
32
+ ctl.handle_cli_input
@@ -0,0 +1,176 @@
1
+ # This is a configuration file for the Taskr RESTful scheduler daemon.
2
+
3
+ # AN IMPORTANT NOTE ABOUT YAML CONFIGURATION FILES:
4
+ # !!! Be sure to use spaces instead of tabs for indentation, as YAML is very
5
+ # !!! sensitive to white-space inconsistencies!
6
+
7
+ ##### HTTP SERVER ##############################################################
8
+
9
+ # Under what HTTP environment are you running the Fluxr server? The following
10
+ # methods are currently supported:
11
+ #
12
+ # webrick -- simple stand-alone HTTP server; this is the default method
13
+ # mongrel -- fast stand-alone HTTP server; much faster than webrick, but
14
+ # you'll have to first install the mongrel gem
15
+ #
16
+
17
+ ### webrick example
18
+
19
+ server: webrick
20
+ port: 7007
21
+
22
+ ### webrick SSL example
23
+
24
+ #server: webrick
25
+ #port: 443
26
+ #ssl_cert: /path/to/your/ssl.pem
27
+
28
+ # if the private key is separate from cert:
29
+ #ssl_key: /path/to/your/private_key.pem
30
+
31
+
32
+ ### mongrel example
33
+
34
+ #server: mongrel
35
+ #port: 7007
36
+
37
+ # It is possible to run mongrel over SSL, but you will need to use a reverse
38
+ # proxy (try Pound or Apache).
39
+
40
+
41
+ ##### DATABASE #################################################################
42
+
43
+ # Taskr needs a database to persist its state between restarts.
44
+ #
45
+ # By default, we use MySQL, since it is widely used and does not require any
46
+ # additional ruby libraries besides ActiveRecord.
47
+ #
48
+ # With MySQL, your config would be something like the following:
49
+ # (be sure to create the taskr database in MySQL beforehand,
50
+ # i.e. `mysqladmin -u root create taskr`)
51
+
52
+ database:
53
+ adapter: mysql
54
+ database: taskr
55
+ username: root
56
+ password:
57
+ host: localhost
58
+
59
+
60
+ # Instead of MySQL you can use SQLite3, PostgreSQL, MSSQL, or anything else
61
+ # supported by ActiveRecord.
62
+ #
63
+ # If you do not have a database server available, you can try using the SQLite3
64
+ # back-end. SQLite3 does not require it's own server. Instead all data is stored
65
+ # in local files. For SQLite3, your configuration would look something like the
66
+ # following (don't forget to install the 'sqlite3-ruby' gem first!):
67
+ #
68
+ #database:
69
+ # adapter: sqlite3
70
+ # dbfile: /var/lib/taskr.db
71
+
72
+
73
+ ##### AUTHENTICATION ###########################################################
74
+
75
+ # Taskr supports two methods for authentication: Basic HTTP and CAS.
76
+
77
+ ### Basic HTTP Example
78
+ # Uset the following if you want Taskr to demand a username and password from
79
+ # the user using basic HTTP authentication clients. Note that this isn't very
80
+ # secure unless you run Taskr over HTTPS (see the webrick SSL example above).
81
+
82
+ #authentication:
83
+ # method: basic
84
+ # username: taskr
85
+ # password: task!
86
+
87
+ ### CAS Example
88
+ # Use the following if you want Taskr to demand a username and password using
89
+ # Single Sign-On CAS (Central Authentication System). For more information on
90
+ # CAS see http://code.google.com/p/rubycas-server/.
91
+ # The cas_base_url setting should be the URL of your CAS server.
92
+
93
+ #authenticatoin:
94
+ # method: cas
95
+ # cas_base_url: https://login.example.foo/cas
96
+
97
+
98
+ ##### LOGGING ##################################################################
99
+
100
+ ### System Log
101
+ # This is the general server log where Taskr writes information about web requests.
102
+ # You'll want to look here if you encounter general problems with Taskr's
103
+ # operation. Do not confuse this log with the task log, which records information
104
+ # about the various schedules jobs. The task log is kept in your database and
105
+ # is completely separate (see below).
106
+ #
107
+ # By default, we will try to create a log file named 'taskr.log' in the current
108
+ # directory (the directory where you're running taskr from). A better place to put
109
+ # the log is in /var/log, but you will have to run taskr as root or otherwise give
110
+ # it permissions.
111
+ #
112
+ # Set the level to DEBUG if you want more detailed logging. Other options are
113
+ # INFO, WARN, and ERROR (DEBUG is most verbose, ERROR is least).
114
+
115
+ log:
116
+ file: taskr.log
117
+ level: DEBUG
118
+ # file: /var/log/taskr.log
119
+ # level: INFO
120
+
121
+ ### Task Log
122
+ # This is where Taskr records detailed information about your scheduled jobs (tasks).
123
+ # Every time a task is triggered, information about the execution is recorded
124
+ # in this log (i.e. whether the task executed successfuly, its output, etc.)
125
+ # The Task Log is stored in the Taskr database under the log_entries table.
126
+ #
127
+ # Here you can configure the logging level. The "INFO" level is generally a good
128
+ # choice for production systems, although you may want to keep this at "DEBUG"
129
+ # if you want to keep a close eye on your tasks -- this is a good idea
130
+ # especially when setting up a new Taskr system.
131
+ #
132
+ # Note that in order to prevent log data from accumulating indefinitely, you
133
+ # should set up a "RotateTaskLog" action in your Taskr server. This will
134
+ # delete old logs as per the parameters you provide (do this via the
135
+ # normal Taskr web interface as you would to set up any other task -- just
136
+ # select "RotateTaskLog" for the action).
137
+
138
+ task_log:
139
+ # ERROR, WARN, INFO, or DEBUG
140
+ level: DEBUG
141
+
142
+
143
+ ##### MISC #####################################################################
144
+
145
+ ### Custom Task Definitions
146
+ # You can define your own task action behaviour by specifying an external ruby
147
+ # filename. On startup, Taskr will load any action definitions from this file,
148
+ # making them available when scheduling new tasks (you should see your custom
149
+ # task classes listed in the Actions pulldown on the new task page).
150
+ #
151
+ # Custom task definitions must:
152
+ # - be defined under the Taskr::Actions module
153
+ # - extend the Taskr::Actions::Base class
154
+ # - implement a 'execute' method (this is what will be executed when your
155
+ # action is triggered)
156
+ # - define a 'parameters' class attribute which should be an Array listing
157
+ # the names of the parameters that your action takes
158
+ # - define a 'description' class attribute which should provide a brief
159
+ # description for what your action does (this will show up in the web UI)
160
+ #
161
+ # Here is an example of a trivial custom action:
162
+ #
163
+ # module Taskr
164
+ # module Actions
165
+ # class MyCustomAction < Taskr::Actions::Base
166
+ # self.parameters = ['alpha', 'beta']
167
+ # self.description = "Multiplies the given parameters and prints the result to stdout."
168
+ #
169
+ # def execute
170
+ # puts parameters['alpha'].to_i * parameters['beta'].to_i
171
+ # end
172
+ # end
173
+ # end
174
+ # end
175
+
176
+ #external_actions: /path/to/file.rb
@@ -0,0 +1,46 @@
1
+ require 'active_resource'
2
+
3
+ # Define the proxy class
4
+ class Task < ActiveResource::Base
5
+ self.site = 'http://taskr.example.com'
6
+ end
7
+
8
+ # Retrieve a list of all the Tasks
9
+ tasks = Task.find(:all)
10
+
11
+ # Print each Task's details for debugging
12
+ tasks.each {|t| puts t.inspect}
13
+
14
+ # Retrieve a specific Task
15
+ task = Task.find(123)
16
+
17
+ # Print the Task's name
18
+ puts task.name
19
+
20
+ # Create a new Task with two actions to be executed every 10 seconds
21
+ task = Task.new
22
+ task.name = "My Example Task"
23
+ task.schedule_method = 'every'
24
+ task.schedule_when = '10s'
25
+ task.actions = [
26
+ {:action_class_name => 'Ruby', :code => "puts 'Sending message through Howlr...'"},
27
+ {:action_class_name => 'Howlr',
28
+ :subject => "Testing Howlr",
29
+ :body => "Just testing! Please ignore this.",
30
+ :from => "joe@example.foo",
31
+ :recipients => "sally@example.foo; bob@example.foo",
32
+ :url => "http://howlr.example.foo/messages.xml",
33
+ :username => 'howlr',
34
+ :password => 'howl!'}
35
+ ]
36
+
37
+ # Save the new Task; saving the Task commits it to the Taskr server
38
+ # and schedules it for execution.
39
+ task.save
40
+
41
+ # Delete the Task we just created
42
+ task.destroy
43
+
44
+ # Or delete a Task with some arbitrary id
45
+ id = 123
46
+ Task.delete(id)