Yii::log from forked thread does not log
Posted 24 June 2009 - 02:47 AM
I'm forking serveral threads (using pcntl_fork) of a Yii CConsoleCommand based program. The launched threads use Yii classes such as CdbConnections and a number of CApplicationComponent based classes of my own without any problems. However calling Yii::log from the threads does not log anything. Any pointers as to where to look?
Posted 01 July 2009 - 09:48 AM
Problem seems to be there is no log->flush method. The threads run till they signal the parent (via a shared mem segment - see Pear-Fork) that they are ready. The parent then posix_kills them. This means the log-array for the thread is never flushed to disk.
I guess best way around this (and to also not run out of memory when running php CConsoleCommand based background apps that log a lot of info) is to write a flushing CFileLogger.
Posted 01 July 2009 - 11:53 AM
It tried adding CApplication::end() to the stop function before it calls the posix_kill
But the Threads are children of an ExecuteThread class so no go. (unless I'm mistaken that is) And also I sometimes want the thread to remain running so I can throw some more work at it.