Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
added monitoring for sevaks
- Loading branch information
1 parent
18737c8
commit afbce7e
Showing
9 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "lib/clojure/clj-record"] | ||
path = lib/clojure/clj-record | ||
url = git://github.com/duelinmarkers/clj-record.git |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
drop database if exists swarmiji_development; | ||
drop database if exists swarmiji_test; | ||
drop database if exists swarmiji_staging; | ||
drop database if exists swarmiji_sandbox; | ||
drop database if exists swarmiji_production; | ||
|
||
create database swarmiji_development; | ||
create database swarmiji_test; | ||
create database swarmiji_staging; | ||
create database swarmiji_sandbox; | ||
create database swarmiji_production; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require "rubygems" | ||
require "activerecord" | ||
|
||
def usage | ||
puts "Swarmiji DB creator." | ||
puts "Usage: schema.rb db-host[localhost|remote.runa.com|etc] db-environment [development|test|production|staging|etc.]" | ||
end | ||
|
||
puts "ARGV.length: #{ARGV.length} ARGV: #{ARGV.inspect}" | ||
|
||
if ARGV.length != 2 | ||
usage | ||
exit -1 | ||
end | ||
|
||
ActiveRecord::Base.establish_connection( | ||
:adapter => "mysql", | ||
:host => ARGV[0], | ||
:database => "swarmiji_#{ARGV[1]}", | ||
:username => "root", | ||
:password => "password" | ||
) | ||
|
||
ActiveRecord::Base.connection.instance_eval do | ||
create_table "control_messages", :force => true do |t| | ||
t.string "sevak_server_pid", "message_type", "sevak_name", "sevak_args", "sevak_time", "messaging_time", "return_q_name" | ||
t.timestamps | ||
end | ||
end | ||
|
||
puts "Created swarmiji_#{ARGV[1]} schema on #{ARGV[0]}." |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/sh | ||
|
||
# Please make sure to configure ~/.clojure.conf or /etc/clojure.conf | ||
# sample configuration can be found at clojure.conf.sample | ||
# | ||
# Note, running this script will: | ||
# - Run ~/.clojurerc on boot up (if exists) | ||
# - Add all .jar files within clj_ext (~/.clojure on default) | ||
# to the classpath | ||
# | ||
# | ||
|
||
if [ ! -f /etc/clojure.conf -a ! -f /mnt/furtive/clojure.conf -a ! -f ~/.clojure.conf ]; then | ||
echo "Error: No config not found at /etc/clojure.conf or ~/.clojure.conf." | ||
echo " Please provide one before starting this script." | ||
echo " A sample can be found in the emacs-clojure repository named " | ||
echo " clojure.conf.sample" | ||
exit | ||
fi | ||
|
||
|
||
# Whether to load the repl or script | ||
if [ -z "$1" ]; then | ||
clj_class=clojure.lang.Repl | ||
else | ||
clj_class=clojure.lang.Script | ||
fi | ||
|
||
echo "SWARMIJI_HOME is ${SWARMIJI_HOME}" | ||
echo "SWARMIJI_ENV is ${SWARMIJI_ENV}" | ||
|
||
swarmiji_jars="${SWARMIJI_HOME}/lib/java" | ||
swarmiji_clj="${SWARMIJI_HOME}/src/:${SWARMIJI_HOME}/lib/clojure/clj-record/src/" | ||
|
||
clj_cp="." | ||
[ -f /etc/clojure.conf ] && . /etc/clojure.conf | ||
[ -f /mnt/furtive/clojure.conf ] && . /mnt/furtive/clojure.conf | ||
[ -f ~/.clojure.conf ] && . ~/.clojure.conf | ||
[ -f ~/.clojurerc ] && clj_rc=~/.clojurerc | ||
clj_cp="${clj_cp}:${swarmiji_jars}/*:${swarmiji_clj}/:${clj_ext}/*" | ||
|
||
if [ -n "${clj_lib}" ]; then | ||
export LD_LIBRARY_PATH=${clj_lib}:$LD_LIBRARY_PATH | ||
fi | ||
|
||
echo exec java -Xms256m -Xmx512m -server -Dpid=$$ ${clj_opts} -cp ${clj_cp}:${clj} ${clj_wrapper} ${clj_class} ${clj_rc} $* | ||
exec java -Xms256m -Xmx512m -server -Dpid=$$ ${clj_opts} -cp ${clj_cp}:${clj} ${clj_wrapper} ${clj_class} ${clj_rc} $1 -- $* |
Submodule clj-record
added at
c8d124
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(ns org.runa.swarmiji.monitor.control_message | ||
(:require clj-record.boot) | ||
(:use [org.runa.swarmiji.config.system-config])) | ||
|
||
(def db (swarmiji-mysql-config)) | ||
(clj-record.core/init-model) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
(ns org.runa.swarmiji.monitor.recorder | ||
(:use [org.runa.swarmiji.mpi.transport]) | ||
(:use [org.runa.swarmiji.config.system-config]) | ||
(:use [org.runa.swarmiji.utils.logger]) | ||
(:use [org.runa.swarmiji.monitor.control_message :as control-message]) | ||
(:import (java.sql Date Time))) | ||
|
||
(defn timestamp-for-sql [time-in-millis] | ||
(str (.toString (Date. time-in-millis)) " " (.toString (Time. time-in-millis)))) | ||
|
||
(defn persist-message [control-message] | ||
(log-message "control-message:" control-message) | ||
(let [now (timestamp-for-sql (System/currentTimeMillis)) | ||
with-timestamps (merge {:created_at now :updated_at now} control-message)] | ||
(control-message/insert with-timestamps))) | ||
|
||
(defn start [] | ||
(let [client (new-queue-client) | ||
q-name (queue-diagnostics-q-name) | ||
handler (queue-message-handler-for-function persist-message)] | ||
(log-message "Swarmiji: Starting Control-Message-Recorder...") | ||
(log-message "Listening on:" q-name) | ||
(.subscribe client q-name handler))) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(use 'org.runa.swarmiji.monitor.recorder) | ||
|
||
(start) |