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 |
Jump to:
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
| Attachment | Size |
|---|---|
| bot.drush_.inc_.txt | 5.02 KB |

#1
oOoOOh, excellent!
#2
Good job jonhattan!
#3
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
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
Should this file be placed the bot module?
#6
yes. It must be places in the bot folder
#7
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...