Yii Framework Forum: Yii::log from forked thread does not log - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Yii::log from forked thread does not log Rate Topic: -----

#1 User is offline   mbetel 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 26-February 09
  • Location:Netherlands

Posted 24 June 2009 - 02:47 AM

Hi,

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?

Thanks,

Michiel
0

#2 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,902
  • Joined: 04-October 08
  • Location:DC, USA

Posted 24 June 2009 - 01:20 PM

Did you list 'log' in 'preload' of your app config?
0

#3 User is offline   mbetel 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 26-February 09
  • Location:Netherlands

Posted 01 July 2009 - 09:48 AM

Yes the log array is ok, main CConsole app logs fine.

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.
0

#4 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,902
  • Joined: 04-October 08
  • Location:DC, USA

Posted 01 July 2009 - 09:55 AM

Do you mean the child threads are ended abruptly?
0

#5 User is offline   mbetel 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 26-February 09
  • Location:Netherlands

Posted 01 July 2009 - 11:53 AM

uhhmm yes :(

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.
0

#6 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,902
  • Joined: 04-October 08
  • Location:DC, USA

Posted 01 July 2009 - 12:26 PM

maybe register a shutdown function?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users