Hey guys. So I am trying to get god to control xrdp. xrdp is a daemon
service, that when run through the init.d script will spawn
itself(xdp) and a helper daemon(sesman). Both of these contain their
own pid files and run independently of eachother, but communicate when
needd. I would like god to maintain xrdp and sesman, but when I create
a watch for xrdp, god will spawn 10-11 processes of xrdp over and over
again. I had thought it was because the init.d script spawns two
processes and two pid files, so that when god starts xrdp, it sees the
pid file of sesman which was not cleaned by the clean_pid_file
behavior. So i wrote my own behaviour which took an array of pid files
and removed those, like such:
God::Watch.class_eval do
attr_accessor :pids
end
module God
module Behaviors
class CleanPids < Behavior
def valid?
valid = true
if self.watch.pids.empty?
valid &= complain("Attribute
'pids' must be specified", self)
end
valid
end
def before_start
self.watch.pids.each {|pidfile|
File.delete(pidfile)}
"deleted all pid files"
rescue
"pid files could not be deleted"
end
end
end
end
I then created this watch for xrdp.
God.watch do |w|
w.name = "xrdp"
w.interval = 5.seconds
w.start = "/etc/init.d/xrdp restart"
w.pids = ["/var/run/xrdp/xrdp.pid", "/var/run/xrdp/sesman.pid"]
w.behavior(:clean_pids)
w.start_if do |start|
start.condition(:process_running) do |c|
c.running = false
end
end
end
Now, when I look at xrdp, I do not see 10 xrdp processes, so I had
though I was successful.
Unfortunantley, if I spam pgrep -f xrdp, every 5 seconds or so(like
the interval, ;p), it will spawn 3 more xrdp sessions, but then
promptly kill the other processes. Now this might be fine, but its
still ugly. Also the sesman process contains logs of it being started/
restarted and the log say sesman is also getting restarted every 5
seconds. Any one see something wrong with my behaviour/watch and/or my
logic? Any suggestions would be very helpful.
--
You received this message because you are subscribed to the Google Groups
"god.rb" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/god-rb?hl=en.