-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to set log_dir as relative path #36
Comments
Hi @daveharris, I have the same problem here. Do you found a solution for this? Thanks, |
Hi @onlinetocode, I eventually set the
Hope that helps. |
Thank you @daveharris, that works perfect! |
It seems the output_logfile and logfile did not use File.expand_path, but the pid dir did. def output_logfile
if log_output_syslog?
'SYSLOG'
elsif log_output?
File.join logdir, output_logfilename
end
end
def logfile
if logdir
File.join logdir, logfilename
end
end
def self.dir(dir_mode, dir, script)
# nil script parameter is allowed as long as dir_mode is not :script
return nil if dir_mode == :script && script.nil?
case dir_mode
when :normal
return File.expand_path(dir)
when :script
return File.expand_path(File.join(File.dirname(script), dir))
when :system
return '/var/run'
else
fail Error.new("pid file mode '#{dir_mode}' not implemented")
end
end Here's my runnable configuration: #!/usr/bin/env ruby
require 'daemons'
base_dir = File.dirname(__FILE__)
file = File.expand_path('utils/process_accuse.rb', base_dir)
options = {
dir_mode: :normal,
dir: File.expand_path('../tmp/pids', base_dir),
monitor: true,
log_dir: File.expand_path('../log', base_dir),
log_output: true,
backtrace: true,
}
Daemons.run_proc(File.basename(file), options) do
exec "ruby #{file}"
end
|
Nice work @lingceng - that certainly explains why |
The project is in what I would call "maintance mode". The discussed issue can certainly be fixed. |
@thuehlinger I believe so yes |
@daveharris I have pushed a fix. Can you test? If everything works as you were hoping for I would then release a new version of the gem. |
@daveharris Did you have the chance to test this change? |
Hey sorry @thuehlinger I haven't. I've moved onto a different project at work so I'm not using |
Hi,
I have a daemon which exists in a rails app so I'm wanting the configure daemons to put the pid and log files in the normal rails directories.
I have this setup:
This creates the pid files in
RAILS_ROOT/tmp/pids
but doesn't create a log file.I tried removing the
log_dir
setting, which creates the file inRAILS_ROOT/tmp/pids
.I tried setting
log_dir: '../../log/',
thinking thatlog_dir
could be relative to thedir
setting. No log file is created. I assume thatlog_dir
is relative to somewhere, but I don't know how.I tried setting
log_dir: '/tmp/',
to an absolute path and that works fine.I have a look at the code:
I see that it's doing
File.join(logdir, output_logfilename)
but where is that relative to?So my question is how can I have the pid files to
tmp/pids
and log file tolog/
? Am I missing something simple?This gems is great, thanks for putting your time into it.
Thanks,
Dave
The text was updated successfully, but these errors were encountered: