This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This task will only be ran once | |
task :foo do | |
unless fetch(:foo_completed, false) do | |
run "whoami" | |
set(:foo_completed, true) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSTRUCTIONS FOR USE | |
==================== | |
Generate the nanite agent | |
$ daemon_kit /path/to/daemon -i nanite_agent | |
Copy the above google.rb into lib/actors/ | |
Open libexec/daemon-daemon.rb and register the actor: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A testament [1] to Handsoap [2], while rewriting the postini gem [3]. This is from git log | |
$ git log --stat 2f91d4d6eaa8bd76c188f20929a19e456d1bb52e..HEAD | grep changed | |
2 files changed, 15 insertions(+), 4 deletions(-) | |
1 files changed, 38 insertions(+), 0 deletions(-) | |
2 files changed, 282 insertions(+), 1 deletions(-) | |
1 files changed, 1 insertions(+), 1 deletions(-) | |
12 files changed, 9 insertions(+), 682 deletions(-) | |
1 files changed, 1 insertions(+), 0 deletions(-) | |
8 files changed, 184 insertions(+), 3883 deletions(-) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kenneth@jenny ~/tmp/dk/crond $ ./bin/crond start | |
kenneth@jenny ~/tmp/dk/crond $ ./bin/crond start | |
Process already running with id 28197 | |
kenneth@jenny ~/tmp/dk/crond $ ./bin/crond start | |
Process already running with id 28197 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# The code below is lifted from a daemon generated with daemon-kit. | |
# | |
# It is responsible for executing various commands on Linux servers to provision | |
# and manage hosting services for several hundred clients on each server. Messages | |
# are delivered to 'identity'-based queues, where each agent can tune into more than | |
# one queue depending on that services they offer. | |
# | |
# The original messages are JSON objects, representing workitems for the | |
# ruote workflow engine. There is some intermediary code that slices up the workitems |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# AMQP generated daemon (this would be the file in libexec/) | |
# | |
# NOTE 1: This config would be adapted to be more ruote-friendly | |
# | |
# NOTE 2: This would be the names of queues used in the process definition, or JID's to use | |
# | |
# NOTE 3: This would be responsible for handling the processesing | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Requirements: | |
# * ruote-2.1.10 or later | |
# * ruote-amqp-2.1.10 or later | |
# * daemon-kit-0.1.8rc3 or later | |
# | |
require 'rubygems' | |
require 'ruote' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Somewhere in a daemon where activerecord is being used | |
# | |
class MyARDaemon | |
include DaemonKit::ActiveRecord | |
def something_ar | |
MyModel.find(:all) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# daemon-kit stack configuration | |
# | |
# severe pseudo-code example | |
# | |
# | |
# config/environment.rb (shared stack) | |
# | |
DaemonKit::Initializer.run do |config| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CrazyIdea < OpenWFE::ProcessDefinition | |
sequence do | |
_loop :break_if => "${f:completed}" do | |
# This is the queue, getting popped by a REST call. The person who did the pop | |
# will have the workitem field 'winner_of_the_lock' set to their details, so the | |
# next participant is dynamic based on that field value. | |
queue_participant | |
# | |
participant "${f:winner_of_the_lock}", :timeout => '1d' |