The Daemons
gem closes all file descriptors when it daemonizes the process. So any logfiles that were opened before the Daemons block will be closed inside the forked process.
And since you can't write to closed file descriptors -> errors.
You can read more about what happens when you daemonize a process by reading the chapter:
What does daemons internally do with my daemons?
http://daemons.rubyforge.org/Daemons.html
The solution is to open the logfile inside the daemon block instead of outside of it. That should fix it. But note that daemonizing changes the working directory to /
, so take that into account when referencing logfile paths.