ruby - Trying to understand GOD rb -


i'm facing few confusion god documentation

firstly configuration script

directory = "/users/joshianiket22/myproject/god_script" god.pid_file_directory = directory god.watch |w|   w.name = "mess"   w.start = "ruby /users/joshianiket22/myproject/god_script/simple.rb"   w.pid_file =  file.join(directory,'simple.pid')   puts file.join(directory,'simple.pid')   w.stop = "ruby -e 'puts \"#{datetime.now}\"'"   w.log = file.join(directory,'god.log')   w.behavior(:clean_pid_file)   w.interval = 10.seconds    w.start_if |start|      start.condition(:process_running) |c|        puts "inside start condition"       c.interval = 5.seconds        c.running = false     end    end  end 

confusion 1 : god pid file dilemma

in god documentation mention

enter image description here

now have clear have set pid_file , pid_file_directory yet pid no seen in directory define in configuration

fyi, started god sudo assuming directory writable god

confusion 2: start_if condition

enter image description here

now how 1 define start_if condition not able understand use case this. word condition conditions set of conditions

  • is :process_running set of condition?, if yes other set of condition start_if
  • also attributes inside do block suppose do? , when executed?

    more precisely referring c.running = false ( internal , other list of attributes available on start_if)

confusion 3 (start/stop/restart command)

now given configuration file has start command written in it, required write stop , restart command in configuration

so when run following

sudo god stop mess
sudo god restart mess

they executed

assuming don't write them

  • what happen if run them ?

  • will god kill running process when stop command i.e sudo god stop mess' executed? or restart running process when restart command i.esudo god restart mess` executed"?

can share light on

confusion 4 (whether or whether not daemonize process):

according god documentation enter image description here

now consider explicitly put process background inside god

w.start = "ruby /users/joshianiket22/myproject/god_script/simple.rb &"  

what happen in such case

  • will god monitor them stop , restart command ?

so daemonizing process inside god (in start command ) can consider valid approach assuming god know process has gone in background , react command start / stop / restart command on process when run against god ?

like

sudo god stop mess
sudo god restart mess

can put light on

so here list of question extracted above

  • why isn't pid_file_directory syntax working?

  • if :process_running set of conditions other conditions start_if contains c.running = false (internally do)

  • is necessary write/define stop , restart in god configuration

  • if process explicity move background god still monitor command stop|restart etc

partially answer part of question

question: necessary write/define stop , restart in god configuration

answer not can define own command if in case dont define there default lambda stop , restart

straight god documentation

enter image description here

question: if process explicity move background god still monitor command stop|restart etc

answer: answer yes , no , no because if dont give god pid file monitor not monitor process running in background

again god documentation

enter image description here

question: if :process_running set of conditions other conditions start_if contains c.running = false (internally do)

answer: answer question in 2 parts

  • what other conditions start_if contains ?

    ans: best place under conditions directory of god check on here there process_running condition exists

  • what c.running = false (internally do)?

    ans: c.running internally used check (the check perform respect process id , running variable) whether process running prior when god start if process i.e(c.running = true) running , pid file pointed has corrected work if c.running = true , pid monitored different or not exist keep looping hence advisable use c.running = true if process running , correct pid_file (with correct pid in is) define in god file . 1 can check on here

note: accepting answer since 1 question left , believe not working because of wrong doing (i.e pid wasn't getting stored in desired directory) :) rest question answered me.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -