Further explanation of...
Caleb G - January 31, 2008 - 04:54
| Project: | Daemon |
| Version: | 5.x-1.x-dev |
| Component: | Documentation |
| Category: | support request |
| Priority: | normal |
| Assigned: | aymerick |
| Status: | needs review |
Jump to:
Description
Hi this sounds like it might be really cool, but honestly I'm not grokking this statement completely:
"... and TADA ! you have an instance of your drupal site running as a daemon in its own process."
Care to expound on that a bit? :-)

#1
From #drupal on IRC (edited for length):
christefano:
can you tell me what the advantage to having daemon module run Drupal as a single process is? I'm looking at the project page and am scratching my headaymerick:
christefano: yeah, you are not the first one to ask me that :p the daemon module goal is not to replace apache ... but you can use it (well, i hope it is usable) if you want a daemon process on your system, doing 'stuff', using the drupal APIs :paymerick:
ok maybe I have to be more explicit on the project page about what this module is notchristefano:
okay, so running Drupal as a daemon will list it in top?aymerick:
yepchristefano:
hmmmm that sounds unbelievably useful. what happens if the daemon is killed?oqp:
could be useful for bot, cron and other bootstrap stuffaymerick:
I haven't finished yet to code all I want, but my goal is to be able to setup Timers that are fired every 'X seconds' (configurable) and that execute any PHP code your want (configurable too)oqp:
christefano you setup the OS to restart it, no?aymerick:
oqp: yeah, as any daemon on your system. you may use some monitoring engine that restart the daemon if it disappearschristefano:
oqp: I mean, does killing the process affect anything other than the daemonaymerick:
christefano: well, not, killing the daemon only affects the daemon (normally). this is very experimental stuff right now... I have to figure out for example what happen with the cache stuff that is shared with a live drupal sitechristefano:
aymerick: with your permission, may I follow up on #216184 with your responses here?aymerick:
christefano: of course you cane :)#2
I have added more explanations on project's page.
#3
I guess this question gets down to what I really am wondering - can this module enable Drupal to be a self contained 'app'. Meaning that someone wouldn't need apache, php, mysql? (sounds very far fetched, but what the heck)
#4
Well, you still need php and mysql, but you don't need apache.
However it doesn't replace apache. The goal is not to allow a daemon to serve pages as apache do, even if it may be possible if you create a Listener that implements full HTTP server, but that's overkill, really, don't do that... except maybe for fun :-)
#5
#6
I still don't understand why running drupal as a daemon could be useful. Can you provide some examples?
#7
I think it's quite good.
I've many useful things in my mind:
- It's good to make some validation tests, simpletests or jmeter tests for specified part of page, and the pages are loaded faster without theme.
- Sometimes the wrong theme hooks kills the Drupal core, so you can fix that without using theme()
- You can make some special debug messages when Drupal run as daemon
- I'll love idea of dumping the content to the shell and parse it, something like:
$ drush deamon --verbose menu node/1 > node1.txt
$ cd public_html && find . -name -exec drush deamon --verbose menu node/{}
$ for %i from 1 to 100; do drush deamon --verbose menu node/%i > my_exported_node_%i.txt
$ drush deamon -listen 21 ftp_module # Drupal handle ftp users and allow them log in using Drupal account details
$ drush deamon -listen 139 share_picture_gallery_in_LAN # LOL
$ drush deamon -listen 8080 drupal_proxy # 220 Drupal: Can I help you?
- Some scheduled cron tasks:
0 10 * * * drush deamon drupal_for_kids &
0 24 * * * killall drush && echo Children go sleep!
- used in some conditional server scripts (Drupal is more secured and firewalled, nobody knows that on this port there is some hidden service)
#!/bin/bash
if ( $user_authorized ) {
drush deamon waiting_for_SOAP_data & # you have 60 seconds for sent logs via SOAP
sleep 60 && killall drush &&
echo Sorry, time out! Thank you for your collecting data.
cdburn ~/public_html/default/all/files/logs/dump.txt
}
- additional security, random listen ports for some short times
- benchmarking server load test:
for %i from 1 to 100; do drush -listen 10%i deamon node; done
- benchmarking Drupal test:
time for %i from 1 to 100; do drush deamon node &; done
- Drupal reniced
renice +20 drush deamon cron.php # please, do that quick
- Drupal renice tests
time renice +10 drush deamon node
time renice -10 drush deamon node
- find the weakest node;)
for %i from 1 to 100; do time drush deamon node/%1; done | sort
etc. etc. ;)