Calling Phirehose functions from an external script

118 views
Skip to first unread message

Gene

unread,
Feb 9, 2012, 3:09:02 PM2/9/12
to Phirehose Users
I am using pcntl_fork() to run phirehose as a php daemon. I also have
a startup file in my etc/init.d directory so that I can stop/start/
restart the daemon by using service daemonName stop/start/restart

I am wondering...if my stream is running just fine in the background,
and I need to update the filter predicates, how do I fire
checkFilterPredicates from outside the script? Such as lets say a user
deactivates their account from the website, I need to fire
checkFilterPredicates to remove them from the stream, however I am not
sure how I would do this from an external process like a web form. I
am doing it just fine in the daemon script. Any help you can provide
is much appreciated. Thank you.

Gene

unread,
Feb 9, 2012, 3:17:08 PM2/9/12
to Phirehose Users
From a technical level, I suppose what I am trying to do is control a
Phirehose daemon by way of PHP sockets. Anyone have experience doing
this?

Fenn Bailey

unread,
Feb 9, 2012, 6:08:32 PM2/9/12
to phireho...@googlegroups.com
Hi Gene,

checkFilterPredicates() is automatically called every N seconds (I think 5 by default). It's designed specifically to get around this issue so you should never need to "call" functions remotely (which is exceedingly messy to do).

The idea is that you look up your current desired filters in the checkFilterPredicates() method - ie: You might get them out of a database, text file, etc - anything you can access from another process. Phirehose also does all the tricky magic to make sure you don't reconfigure your stream too often - if you do this, you'll get banned by Twitter (too many reconnects). This is all taken care of for you.

You can see an example of this in the filter-reconfigure.php file in the examples dir bundled with Phirehose.

That makes the whole thing a lot simpler - basically, if you want to update your filters, simply write the new filters to the DB... that's it... not restarting Phirehose, calling methods, etc - it will do that for you at the next checkFilterPredicates() call.

Make sense?

Cheers,

 Fenn.

Gene Ellis

unread,
Feb 9, 2012, 6:44:38 PM2/9/12
to phireho...@googlegroups.com
Ahhhh. ok. That makes sense and also makes things a ton easier. So basically I need to move all my database lookup code into the  checkFilterPredicates()  method so that every N seconds, it goes ahead and looks everything up. Makes perfect sense. Thanks! I was about to embark down the socket path. Score. 

jhku...@gmail.com

unread,
Jul 22, 2012, 5:44:34 PM7/22/12
to phireho...@googlegroups.com
In the php script connecting to the stream the trackwords are initialy set via setTrack.

Why isn't it possible to keep the php script running and set other trackwords when needed via setTrack instead of via checkFilterPredicates?
Reply all
Reply to author
Forward
0 new messages