thuehlinger / daemons

Ruby daemons gem official repository
MIT License
648 stars 71 forks source link

Stopping daemon log file error? #53

Open pgouv opened 7 years ago

pgouv commented 7 years ago

When I am trying to stop I get this message written: Config:

Daemons.run(
  MYD_PATH,
  app_name: 'my_daemon',
  dir_mode:          :normal,
  dir:                TMP_PIDS_DIR,
  backtrace:          true,
  monitor:            true,
  log_output:         true,
  logfilename:        'daemon.log',
  output_logfilename: 'outputfile.txt',
  mode:               :load
)

SIGTERM ["/usr/local/lib/ruby/gems/2.3/gems/daemons-1.2.4/lib/daemons/monitor.rb:56:in sleep'", "/usr/local/lib/ruby/gems/2.3/gems/daemons-1.2.4/lib/daemons/monitor.rb:56:inblock in watch'", "/usr/local/lib/ruby/gems/2.3/gems/daemons-1.2.4/lib/daemons/monitor.rb:43:in loop'", "/usr/local/lib/ruby/gems/2.3/gems/daemons-1.2.4/lib/daemons/monitor.rb:43:inwatch'", "/usr/local/lib/ruby/gems/2.3/gems/daemons-1.2.4/lib/daemons/monitor.rb:67:in block in start_with_pidfile'", "/usr/local/lib/ruby/gems/2.3/gems/daemons-1.2.4/lib/daemons/monitor.rb:62:infork'", "/usr/local/lib/ruby/gems/2.3/gems/daemons-1.2.4/lib/daemons/monitor.rb:62:in start_with_pidfile'", "/usr/local/lib/ruby/gems/2.3/gems/daemons-1.2.4/lib/daemons/monitor.rb:93:instart'", "/usr/local/lib/ruby/gems/2.3/gems/daemons-1.2.4/lib/daemons/application_group.rb:147:in create_monitor'", "/usr/local/lib/ruby/gems/2.3/gems/daemons-1.2.4/lib/daemons/application.rb:284:instart'", "/usr/local/lib/ruby/gems/2.3/gems/daemons-1.2.4/lib/daemons/controller.rb:56:in run'", "/usr/local/lib/ruby/gems/2.3/gems/daemons-1.2.4/lib/daemons.rb:148:inblock in run'", "/usr/local/lib/ruby/gems/2.3/gems/daemons-1.2.4/lib/daemons/cmdline.rb:92:in catch_exceptions'", "/usr/local/lib/ruby/gems/2.3/gems/daemons-1.2.4/lib/daemons.rb:147:inrun'", "/usr/local/lib/ruby/gems/2.3/gems/xxxxxx-0.1.14/bin/daemonctl23:10:in <top (required)>'", "/usr/local/bin/daemonctl23:23:inload'", "/usr/local/bin/daemonctl23:23:in `

'"]

thuehlinger commented 7 years ago

Where do you get this output? STDOUT? STDERR?

Does your script get stopped as it should and is the .pid file correctly removed? Can you confirm that the monitor process terminates correctly?

andreac92 commented 7 years ago

Hi,

We're getting the same exact SIGTERM errors.

Our .pid file gets removed correctly, and the monitor process and script terminate. Any ideas what could be causing this?

thuehlinger commented 7 years ago

So far, unfortunately, not. Any chance you can prepare a minimal example that shows this behaviour? This would be very helpful for me for testing.

pgouv commented 7 years ago

I will create a repo with this. With little digging this error seems to occur with monitoring. My guess is since watch is a never ending loop with sleep, when app is terminated due to SIGTERM , exception is caught and logged here https://github.com/thuehlinger/daemons/blob/master/lib/daemons/monitor.rb#L65