I am trying to run a Ruby daemon using the daemons
gem.
It will be started as user 'joe' but needs to change to 'www-data' once it's demonized so that it can access the files it will be working on.
I can see that daemons has change_privilege
method for the Application class, but I can't figure out how to use it around this code:
require 'daemons'
Daemons.run(
File.join(File.dirname(__FILE__), 'worker.rb'),
{
:backtrace => true,
:log_output => true,
:dir_mode => :script,
:log_dir => '/tmp',
:monitor => true
}
)
You should not be running as www-data
as this is a specific user to apache. You should however add "joe" to your www user group that can access such files.