# File lib/daemons/application.rb, line 154 def start_proc return unless p = options[:proc] myproc = proc do # We need this to remove the pid-file if the applications exits by itself. # Note that <tt>at_text</tt> will only be run if the applications exits by calling # <tt>exit</tt>, and not if it calls <tt>exit!</tt> (so please don't call <tt>exit!</tt> # in your application! # at_exit { @pid.cleanup rescue nil # If the option <tt>:backtrace</tt> is used and the application did exit by itself # create a exception log. if options[:backtrace] and not options[:ontop] and not $daemons_sigterm exception_log() rescue nil end } # This part is needed to remove the pid-file if the application is killed by # daemons or manually by the user. # Note that the applications is not supposed to overwrite the signal handler for # 'TERM'. # trap('TERM') { @pid.cleanup rescue nil $daemons_sigterm = true exit } p.call() end unless options[:ontop] @pid.pid = Daemonize.call_as_daemon(myproc, logfile, @group.app_name) else Daemonize.simulate(logfile) @pid.pid = Process.pid myproc.call # why did we use this?? # Thread.new(&options[:proc]) # why did we use the code below?? # unless pid = Process.fork # @pid.pid = pid # Daemonize.simulate(logfile) # options[:proc].call # exit # else # Process.detach(@pid.pid) # end end end