daemonize the bot with drush

jonhattan - July 19, 2009 - 13:08
Project:Bot
Version:6.x-1.x-dev
Component:Code
Category:task
Priority:normal
Assigned:Unassigned
Status:needs review
Description

Attached is a drush.inc file that exposes following commands:

drush bot start
drush bot stop
drush bot restart
drush bot status

Bot is daemonized upon start and a pid file is stored at $SITE/bot.pid

AttachmentSize
bot.drush_.inc_.txt5.02 KB

#1

Morbus Iff - July 19, 2009 - 13:29

oOoOOh, excellent!

#2

kurkuma - July 20, 2009 - 09:23

Good job jonhattan!

#3

Morbus Iff - July 20, 2009 - 10:22

I'm curious - can we get rid of bot_start.php entirely by moving to a dependency on Drush? Can the 'start' command handle the loading of the IRC library, and make Drush the forever-running process?

#4

jonhattan - July 21, 2009 - 17:22

My first attempt was to just include bot_start.php in the child code and it didn't worked. So I used the function pcntl_exec that allows to exec an external process by replacing current one.

Now I just tried moving bot_start.php's code to a function in bot.drush.inc and slightly modifying the ARGV code. The error is the same... Warning: MySQL server has gone away... I've also trying removing the bootstrap as drush already has bootstrapped drupal... same error.

Its weird but when I commented out require_once('Net/SmartIRC.php'); the mysql error dissapeared... if I move the require after the first connection to mysql (db_query('SET SESSION wait_timeout = %d', 24*60*60);) that query doesn't raise the error... but next ones do it. Any idea ?
EDIT: it is just a problem of milliseconds. Mysql will fail anyway.... once the parent process (drush) ends its execution. bootstraping drupal again does not solve it.

So I think that to drop bot_start.php completely --if possible-- requires more knowledge about drush internals a/o process handling with php.

#5

jackinloadup - July 28, 2009 - 03:36

Should this file be placed the bot module?

#6

jonhattan - July 30, 2009 - 14:38

yes. It must be places in the bot folder

#7

jonhattan - August 16, 2009 - 13:40

I've revisited the code to make some little changes. No functionality added / changed. I've commited it to my cvs sandbox in order to let me have the code more at hand and track changes.

http://cvs.drupal.org/viewvc.py/drupal/contributions/sandbox/jonhattan/d...

 
 

Drupal is a registered trademark of Dries Buytaert.