jah 0.0.3 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/README.md +62 -13
  2. data/Rakefile +4 -3
  3. data/VERSION +1 -1
  4. data/bin/jah +4 -2
  5. data/jah.gemspec +73 -21
  6. data/lib/jah/act_pkg/apt.rb +13 -0
  7. data/lib/jah/act_pkg/base.rb +17 -0
  8. data/lib/jah/act_pkg/emerge.rb +4 -0
  9. data/lib/jah/act_pkg/pacman.rb +59 -0
  10. data/lib/jah/act_pkg/pkg.rb +52 -0
  11. data/lib/jah/act_pkg/ports.rb +9 -0
  12. data/lib/jah/act_pkg/slack.rb +8 -0
  13. data/lib/jah/act_pkg/urpm.rb +7 -0
  14. data/lib/jah/act_pkg/yum.rb +31 -0
  15. data/lib/jah/act_pkg/zypp.rb +12 -0
  16. data/lib/jah/act_pkg.rb +41 -0
  17. data/lib/jah/agent.rb +14 -6
  18. data/lib/jah/agents/xmpp.rb +164 -23
  19. data/lib/jah/cli.rb +15 -46
  20. data/lib/jah/command.rb +10 -5
  21. data/lib/jah/commands/cpu.rb +38 -0
  22. data/lib/jah/commands/disk.rb +35 -0
  23. data/lib/jah/commands/mem.rb +49 -0
  24. data/lib/jah/{collectors/net.rb → commands/netstat.rb} +11 -9
  25. data/lib/jah/commands/packages.rb +25 -0
  26. data/lib/jah/commands/prok.rb +97 -0
  27. data/lib/jah/commands/services.rb +14 -0
  28. data/lib/jah/commands/status.rb +1 -41
  29. data/lib/jah/commands/who.rb +27 -0
  30. data/lib/jah/history.rb +25 -0
  31. data/lib/jah/install.rb +12 -18
  32. data/lib/jah/opt.rb +87 -0
  33. data/lib/jah/prayer.rb +75 -0
  34. data/lib/jah.rb +21 -13
  35. data/lib/locales/en_us.yml +9 -1
  36. data/lib/locales/pt_br.yml +9 -1
  37. data/spec/jah/act_pkg/apt_spec.rb +40 -0
  38. data/spec/jah/act_pkg/pacman_spec.rb +141 -0
  39. data/spec/jah/act_pkg/pkg_spec.rb +51 -0
  40. data/spec/jah/act_pkg/ports_spec.rb +36 -0
  41. data/spec/jah/act_pkg/yum_spec.rb +55 -0
  42. data/spec/jah/act_pkg_spec.rb +41 -0
  43. data/spec/jah/agent_spec.rb +8 -0
  44. data/spec/jah/agents/xmpp_spec.rb +8 -0
  45. data/spec/jah/cli_spec.rb +47 -0
  46. data/spec/jah/command_spec.rb +5 -0
  47. data/spec/jah/commands/cpu_spec.rb +51 -0
  48. data/spec/jah/commands/disk_spec.rb +49 -0
  49. data/spec/jah/commands/mem_spec.rb +60 -0
  50. data/spec/jah/commands/netstat_spec.rb +13 -0
  51. data/spec/jah/commands/prok_spec.rb +248 -0
  52. data/spec/jah/commands/who_spec.rb +25 -0
  53. data/spec/jah/history_spec.rb +35 -0
  54. data/spec/jah/install_spec.rb +15 -0
  55. data/spec/jah/opt_spec.rb +37 -0
  56. data/spec/jah/prayer_spec.rb +8 -0
  57. data/spec/jah_spec.rb +4 -2
  58. data/spec/spec_helper.rb +3 -1
  59. metadata +67 -16
  60. data/lib/jah/collector.rb +0 -12
  61. data/lib/jah/collectors/cpu.rb +0 -35
  62. data/lib/jah/collectors/disk.rb +0 -14
  63. data/lib/jah/collectors/mem.rb +0 -51
  64. data/lib/jah/collectors/prok.rb +0 -88
  65. data/lib/jah/collectors/services.rb +0 -13
  66. data/lib/jah/collectors/who.rb +0 -20
  67. data/lib/jah/commands/pub.rb +0 -34
  68. data/lib/jah/god.rb +0 -24
  69. data/lib/jah.yaml.template +0 -26
data/README.md CHANGED
@@ -6,14 +6,21 @@ Talk to your machines. Like a god.
6
6
 
7
7
  Just run it for the first time to create a config file.
8
8
  Use `jah install` to force the wizard again.
9
+ Jah will try to find a `jah.yaml` file on ~/.jah or /etc.
9
10
 
10
- Gems needed for XMPP mode:
11
11
 
12
- * EventMachine (gem install eventmachine)
13
- * Blather (gem install blather)
12
+ ## Support
14
13
 
14
+ * ArchLinux (tested)
15
+ * Mac OS X (tested)
16
+ * CentOS (tested)
17
+ * Debian (tested)
18
+ * BSD
15
19
 
16
- Jah will try to find a `jah.yaml` file on ~/.jah or /etc.
20
+ Gems required for XMPP mode:
21
+
22
+ * Blather
23
+ * EventMachine
17
24
 
18
25
 
19
26
  ## Modes
@@ -37,8 +44,6 @@ AkA: Security freak. Jah just writes to tmp/ or whatever a dump file,
37
44
  Jah Web securely connects (scp) and downloads the data to parse.
38
45
 
39
46
 
40
- ## Use God?
41
-
42
47
 
43
48
  ## XMPP Bot
44
49
 
@@ -80,25 +85,68 @@ Group session:
80
85
  me: ok?
81
86
  msweet: I'm fine, thanks..
82
87
  ssaint: Kinda busy right now..
83
- naomi: I need you! Now!
88
+ naomi: I need you! NOW!
89
+
90
+
91
+ ### System commands
92
+
93
+
94
+ ## PubSub
95
+
96
+ Create a pubsub:
97
+
98
+ pub create foo
99
+ jah: Done.
100
+
101
+ Publish to it:
102
+
103
+ foo: pubbin and dubbin from jah!
104
+ jah: Published.
105
+
106
+ My pubs:
107
+
108
+ pub mine
109
+ jah: Pubsubs
110
+ Owner: foo
111
+
112
+ All pubs:
84
113
 
114
+ pub all
115
+ jah: All Pubsubs
116
+ => /foo
117
+ => /bar
85
118
 
86
- Execute God statements:
119
+ Subscribe to bar:
120
+
121
+ pub sub bar
122
+ jah: Done.
123
+
124
+
125
+ Unsubscribe to bar:
126
+
127
+ pub unsub bar
128
+ jah:Done.
129
+
130
+
131
+ Destroy a pub:
132
+
133
+ pub destroy foo
134
+ jah: Done.
135
+
136
+
137
+ ## Use God?
138
+
139
+ ### God commands
87
140
 
88
141
  Start, stop, restart, monitor and unmonitor words on the beginning
89
142
  of a phrase will make Jah add a "god" on the front of it, making it
90
143
  trivial to work with your services:
91
144
 
92
-
93
145
  start nginx
94
146
  restart nanites
95
147
  unmonitor postgresql
96
148
 
97
149
 
98
- More to come...
99
-
100
-
101
-
102
150
  ## Note on Patches/Pull Requests
103
151
 
104
152
  * Fork the project.
@@ -110,6 +158,7 @@ More to come...
110
158
  bump version in a commit by itself I can ignore when I pull)
111
159
  * Send me a pull request. Bonus points for topic branches.
112
160
 
161
+
113
162
  ## Copyright
114
163
 
115
164
  Copyright (c) 2009 Marcos Piccinini. See LICENSE for details.
data/Rakefile CHANGED
@@ -5,14 +5,15 @@ begin
5
5
  require 'jeweler'
6
6
  Jeweler::Tasks.new do |gem|
7
7
  gem.name = "jah"
8
- gem.summary = "be omnipresent..."
9
- gem.description = "talk to your machines"
8
+ gem.summary = "Be omnipresent..."
9
+ gem.description = "Talk to your machines. Like a God."
10
10
  gem.email = "x@nofxx.com"
11
11
  gem.homepage = "http://github.com/nofxx/jah"
12
12
  gem.authors = ["Marcos Piccinini"]
13
- gem.add_dependency "blather"
13
+ gem.add_dependency "blather", '>=0.4.7'
14
14
  gem.add_dependency "i18n"
15
15
  gem.add_development_dependency "rspec"
16
+ # gem.add_development_dependency "rr"
16
17
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
18
  end
18
19
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.5
data/bin/jah CHANGED
@@ -3,7 +3,9 @@
3
3
  $VERBOSE = true # -w
4
4
  $KCODE = "u" # -Ku
5
5
 
6
- $LOAD_PATH << File.join(File.dirname(__FILE__), *%w[.. lib])
6
+ # $LOAD_PATH << File.join(File.dirname(__FILE__), *%w[.. lib])
7
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
7
8
  require "jah"
9
+ include Jah
8
10
 
9
- Jah::Cli.dispatch(ARGV)
11
+ Jah::Cli.work(ARGV)
data/jah.gemspec CHANGED
@@ -1,17 +1,17 @@
1
1
  # Generated by jeweler
2
- # DO NOT EDIT THIS FILE
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{jah}
8
- s.version = "0.0.3"
8
+ s.version = "0.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Marcos Piccinini"]
12
- s.date = %q{2009-09-29}
12
+ s.date = %q{2009-11-26}
13
13
  s.default_executable = %q{jah}
14
- s.description = %q{talk to your machines}
14
+ s.description = %q{Talk to your machines. Like a God.}
15
15
  s.email = %q{x@nofxx.com}
16
16
  s.executables = ["jah"]
17
17
  s.extra_rdoc_files = [
@@ -28,33 +28,64 @@ Gem::Specification.new do |s|
28
28
  "bin/jah",
29
29
  "jah.gemspec",
30
30
  "lib/jah.rb",
31
- "lib/jah.yaml.template",
31
+ "lib/jah/act_pkg.rb",
32
+ "lib/jah/act_pkg/apt.rb",
33
+ "lib/jah/act_pkg/base.rb",
34
+ "lib/jah/act_pkg/emerge.rb",
35
+ "lib/jah/act_pkg/pacman.rb",
36
+ "lib/jah/act_pkg/pkg.rb",
37
+ "lib/jah/act_pkg/ports.rb",
38
+ "lib/jah/act_pkg/slack.rb",
39
+ "lib/jah/act_pkg/urpm.rb",
40
+ "lib/jah/act_pkg/yum.rb",
41
+ "lib/jah/act_pkg/zypp.rb",
32
42
  "lib/jah/agent.rb",
33
43
  "lib/jah/agents/dump.rb",
34
44
  "lib/jah/agents/post.rb",
35
45
  "lib/jah/agents/xmpp.rb",
36
46
  "lib/jah/cli.rb",
37
- "lib/jah/collector.rb",
38
- "lib/jah/collectors/cpu.rb",
39
- "lib/jah/collectors/disk.rb",
40
- "lib/jah/collectors/mem.rb",
41
- "lib/jah/collectors/net.rb",
42
- "lib/jah/collectors/prok.rb",
43
- "lib/jah/collectors/services.rb",
44
- "lib/jah/collectors/who.rb",
45
47
  "lib/jah/command.rb",
46
48
  "lib/jah/commands/admin.rb",
49
+ "lib/jah/commands/cpu.rb",
50
+ "lib/jah/commands/disk.rb",
47
51
  "lib/jah/commands/extra.rb",
48
- "lib/jah/commands/pub.rb",
52
+ "lib/jah/commands/mem.rb",
53
+ "lib/jah/commands/netstat.rb",
54
+ "lib/jah/commands/packages.rb",
55
+ "lib/jah/commands/prok.rb",
56
+ "lib/jah/commands/services.rb",
49
57
  "lib/jah/commands/status.rb",
50
- "lib/jah/god.rb",
58
+ "lib/jah/commands/who.rb",
59
+ "lib/jah/history.rb",
51
60
  "lib/jah/install.rb",
61
+ "lib/jah/opt.rb",
62
+ "lib/jah/prayer.rb",
52
63
  "lib/locales/en_us.yml",
53
64
  "lib/locales/pt_br.yml",
54
65
  "lib/locales/pt_br_gostosa.yml",
55
66
  "lib/locales/pt_br_mano.yml",
56
67
  "lib/locales/pt_br_mineiro.yml",
57
68
  "spec/console",
69
+ "spec/jah/act_pkg/apt_spec.rb",
70
+ "spec/jah/act_pkg/pacman_spec.rb",
71
+ "spec/jah/act_pkg/pkg_spec.rb",
72
+ "spec/jah/act_pkg/ports_spec.rb",
73
+ "spec/jah/act_pkg/yum_spec.rb",
74
+ "spec/jah/act_pkg_spec.rb",
75
+ "spec/jah/agent_spec.rb",
76
+ "spec/jah/agents/xmpp_spec.rb",
77
+ "spec/jah/cli_spec.rb",
78
+ "spec/jah/command_spec.rb",
79
+ "spec/jah/commands/cpu_spec.rb",
80
+ "spec/jah/commands/disk_spec.rb",
81
+ "spec/jah/commands/mem_spec.rb",
82
+ "spec/jah/commands/netstat_spec.rb",
83
+ "spec/jah/commands/prok_spec.rb",
84
+ "spec/jah/commands/who_spec.rb",
85
+ "spec/jah/history_spec.rb",
86
+ "spec/jah/install_spec.rb",
87
+ "spec/jah/opt_spec.rb",
88
+ "spec/jah/prayer_spec.rb",
58
89
  "spec/jah_spec.rb",
59
90
  "spec/spec_helper.rb"
60
91
  ]
@@ -62,9 +93,29 @@ Gem::Specification.new do |s|
62
93
  s.rdoc_options = ["--charset=UTF-8"]
63
94
  s.require_paths = ["lib"]
64
95
  s.rubygems_version = %q{1.3.5}
65
- s.summary = %q{be omnipresent...}
96
+ s.summary = %q{Be omnipresent...}
66
97
  s.test_files = [
67
- "spec/jah_spec.rb",
98
+ "spec/jah/cli_spec.rb",
99
+ "spec/jah/agents/xmpp_spec.rb",
100
+ "spec/jah/install_spec.rb",
101
+ "spec/jah/commands/mem_spec.rb",
102
+ "spec/jah/commands/cpu_spec.rb",
103
+ "spec/jah/commands/who_spec.rb",
104
+ "spec/jah/commands/netstat_spec.rb",
105
+ "spec/jah/commands/disk_spec.rb",
106
+ "spec/jah/commands/prok_spec.rb",
107
+ "spec/jah/agent_spec.rb",
108
+ "spec/jah/command_spec.rb",
109
+ "spec/jah/act_pkg/yum_spec.rb",
110
+ "spec/jah/act_pkg/apt_spec.rb",
111
+ "spec/jah/act_pkg/pkg_spec.rb",
112
+ "spec/jah/act_pkg/ports_spec.rb",
113
+ "spec/jah/act_pkg/pacman_spec.rb",
114
+ "spec/jah/opt_spec.rb",
115
+ "spec/jah/act_pkg_spec.rb",
116
+ "spec/jah/prayer_spec.rb",
117
+ "spec/jah/history_spec.rb",
118
+ "spec/jah_spec.rb",
68
119
  "spec/spec_helper.rb"
69
120
  ]
70
121
 
@@ -73,17 +124,18 @@ Gem::Specification.new do |s|
73
124
  s.specification_version = 3
74
125
 
75
126
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
76
- s.add_runtime_dependency(%q<blather>, [">= 0"])
127
+ s.add_runtime_dependency(%q<blather>, [">= 0.4.7"])
77
128
  s.add_runtime_dependency(%q<i18n>, [">= 0"])
78
129
  s.add_development_dependency(%q<rspec>, [">= 0"])
79
130
  else
80
- s.add_dependency(%q<blather>, [">= 0"])
131
+ s.add_dependency(%q<blather>, [">= 0.4.7"])
81
132
  s.add_dependency(%q<i18n>, [">= 0"])
82
133
  s.add_dependency(%q<rspec>, [">= 0"])
83
134
  end
84
135
  else
85
- s.add_dependency(%q<blather>, [">= 0"])
136
+ s.add_dependency(%q<blather>, [">= 0.4.7"])
86
137
  s.add_dependency(%q<i18n>, [">= 0"])
87
138
  s.add_dependency(%q<rspec>, [">= 0"])
88
139
  end
89
140
  end
141
+
@@ -0,0 +1,13 @@
1
+
2
+ module Jah
3
+ class Apt < ActPkg::Base
4
+ BIN = "aptitude"
5
+
6
+
7
+ def self.all
8
+ "dpkg -l"
9
+ end
10
+
11
+
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ module Jah
2
+ module ActPkg
3
+
4
+ class Base
5
+
6
+
7
+ def install(comm = "install")
8
+ BIN + comm
9
+ end
10
+
11
+ def run(comm)
12
+ `#{comm}`
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,4 @@
1
+ module Jah
2
+
3
+
4
+ end
@@ -0,0 +1,59 @@
1
+
2
+ module Jah
3
+
4
+ class Pacman < ActPkg::Base
5
+
6
+ # -Q installed packages
7
+ def all(filter = nil)
8
+ res = run("pacman -Q").to_a.map do |line|
9
+ Pkg.new(:installed, *line.split(" "))
10
+ end
11
+ res.select { |p| p.name =~ /#{filter}/ } if filter
12
+ res
13
+ end
14
+
15
+ # -Ss /regex/ search all pkgs
16
+ def search(filter = nil)
17
+ pkgs = []
18
+ installed = all(filter) # until figure out a memoize for all this
19
+ run("pacman -Ss #{filter}").to_a.each_slice(2) do |info, desc|
20
+ name, version, size = info.split("/")[1].split(" ")
21
+ state = installed.find { |i| i.name == name }
22
+ pkgs << Pkg.new(state ? :installed : :new, name, version, desc.strip)
23
+ end
24
+ pkgs
25
+ end
26
+
27
+ # -Qi info about a pkg (only installed ones)
28
+ def info(pkg)
29
+ ary = run("pacman -Qi #{pkg.name}").to_a
30
+ return nil if ary[0] =~ /error/
31
+ ary.map! do |i|
32
+ val = i.split("\s:\s")[1]
33
+ val.strip if val
34
+ end #.reject(&:nil?)
35
+ { :url => ary[2], :license => ary[3], :groups => ary[4], :provides => ary[5],
36
+ :depends => ary[6], :required => ary[8], :size => ary[12], :arch => ary[14],
37
+ :desc => ary[19]}
38
+ end
39
+
40
+ def install(pkgs)
41
+ pkgs = [pkgs] unless pkgs.class == Array
42
+ run "pacman -Sy --noconfirm #{pkgs.map(&:name).join(' ')}"
43
+ end
44
+
45
+ def uninstall(pkg)
46
+ run "pacman -R --noconfirm #{pkg.name}"
47
+ end
48
+
49
+ def upgrade(pkg)
50
+ run "pacman -U --noconfirm #{pkg.name}"
51
+ end
52
+
53
+ def update
54
+ run "pacman -Syu"
55
+ end
56
+
57
+ end
58
+
59
+ end
@@ -0,0 +1,52 @@
1
+ module Jah
2
+
3
+ class Pkg
4
+ include Comparable
5
+ attr_reader :name, :version, :status, :size
6
+
7
+ def initialize(*args)
8
+ @status, @name, @version, @desc = args
9
+ end
10
+
11
+ def desc
12
+ @desc ||= info[:desc]
13
+ end
14
+
15
+ def info
16
+ @info ||= ActPkg.info(self)
17
+ end
18
+
19
+ def installed?
20
+ @status == :installed
21
+ end
22
+
23
+ def install
24
+ ActPkg.install(self)
25
+ end
26
+
27
+ def uninstall
28
+ end
29
+
30
+ def ==(other)
31
+ (name == other.name) && (version == other.version)
32
+ end
33
+
34
+ def <=>(other)
35
+ raise "Not same pkg.." unless name == other.name
36
+ version <=> other.version
37
+ end
38
+
39
+ def valid?
40
+ !(@name.nil? or @version.nil?)
41
+ end
42
+
43
+
44
+ def method_missing(*meth)
45
+ unless (val = info[meth[0]]).nil?
46
+ val
47
+ else
48
+ raise NoMethodError
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,9 @@
1
+
2
+ module Jah
3
+
4
+ class Ports < ActPkg::Base
5
+
6
+
7
+
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ module Jah
2
+
3
+ class Slack < ActPkg::Base
4
+
5
+ end
6
+
7
+
8
+ end
@@ -0,0 +1,7 @@
1
+ module Jah
2
+ class Urpm < ActPkg::Base
3
+
4
+
5
+
6
+ end
7
+ end
@@ -0,0 +1,31 @@
1
+ module Jah
2
+
3
+
4
+ class Yum < ActPkg::Base
5
+
6
+ def all(filter = nil)
7
+ run("yum -q list installed").to_a[1..-1].map do |l|
8
+ name, version = l.split(" ")[0..1]
9
+ Pkg.new(:installed, name.split(".i")[0], version )
10
+ end
11
+ end
12
+
13
+ # all pkgs...search repo
14
+ def info(pkg)
15
+
16
+ end
17
+
18
+ def install(what)
19
+ "yum install #{what}"
20
+ end
21
+
22
+ def uninstall
23
+ "remove"
24
+ end
25
+
26
+ def update
27
+ "check-update"
28
+ end
29
+ end
30
+
31
+ end
@@ -0,0 +1,12 @@
1
+ module Jah
2
+
3
+
4
+ class Zypp < ActPkg::Base
5
+ BIN = "zypper"
6
+
7
+
8
+
9
+
10
+ end
11
+
12
+ end
@@ -0,0 +1,41 @@
1
+ #
2
+ # ActPkg - Say 'install' and it works =D
3
+ #
4
+ # Nice tables:
5
+ # http://distrowatch.com/dwres.php?resource=package-management
6
+ # http://www.guiadohardware.net/dicas/referencia-pacotes-linux.html
7
+ #
8
+ module Jah
9
+
10
+ module ActPkg
11
+ autoload :Pacman, "jah/act_pkg/pacman"
12
+
13
+ def self.detect
14
+ if RUBY_PLATFORM =~ /darwin/
15
+ :ports
16
+ else
17
+ case File.read("/etc/issue")
18
+ when /Arch/i then :pacman
19
+ when /SUSE/i then :zypp
20
+ when /Mandriva/ then :urpm
21
+ when /BSD/ then :ports
22
+ when /Fedora|CentOS/ then :yum
23
+ when /Debian|Ubuntu/ then :apt
24
+ when /This|Gentoo/ then :emerge
25
+ when /Welcome|Slack/ then :slack
26
+ else
27
+ raise "Is this LFS??"
28
+ end
29
+ end
30
+ end
31
+
32
+ def self.manager
33
+ @manager ||= const_get(detect.to_s.capitalize).new
34
+ end
35
+
36
+ def self.method_missing(*meth)
37
+ manager.send(*meth)
38
+ end
39
+ end
40
+
41
+ end
data/lib/jah/agent.rb CHANGED
@@ -13,7 +13,7 @@ module Jah
13
13
  autoload :DumpAgent, "jah/agents/xmpp"
14
14
 
15
15
  def initialize(options=nil)#, config)
16
- if Jah.daemon?
16
+ if Opt.daemon?
17
17
  puts "Jah starting in background.."
18
18
  fork do
19
19
  daemonize
@@ -29,16 +29,19 @@ module Jah
29
29
  end
30
30
 
31
31
  def run_agent_run
32
- case Jah.mode # @mode
32
+ case Opt.mode # @mode
33
33
  when "xmpp" then XmppAgent.new.run
34
34
  when "post" then PostAgent.new.run
35
- else
36
- DumpAgent.new
35
+ else DumpAgent.new
37
36
  end
38
37
  end
39
38
 
40
39
  def self.start
41
- new
40
+ if File.exists?(PID_FILE)
41
+ puts "Jah already running...#{PID_FILE}"
42
+ else
43
+ new
44
+ end
42
45
  end
43
46
 
44
47
  def self.stop
@@ -54,13 +57,18 @@ module Jah
54
57
 
55
58
  def self.restart
56
59
  stop
60
+ sleep 2
57
61
  start
58
62
  end
59
63
 
60
- def self.install
64
+ def self.config
61
65
  Install.new
62
66
  end
63
67
 
68
+ class << self
69
+ alias :install :config
70
+ end
71
+
64
72
  def daemonize
65
73
  begin
66
74
  File.open(pid_file, File::CREAT|File::EXCL|File::WRONLY) do |pid|