Thanks to the daemon module you can run daemon instances of a drupal site.
Create a daemon configuration with the administration UI, then launch it in a terminal with a command like:
$ drush daemon my_daemon_name
... and TADA ! you have an instance of your drupal site running as a daemon in its own process.
The goal of this module is NOT to replace apache, but you can use it if you want a daemon process on your system doing 'stuff' using the drupal APIs.
I repeat: The main 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 a full HTTP server, but that's overkill, really, don't do that... except maybe for fun.
Sponsored by newlc.com
- drush module - You should setup the drush alias as explained in drush module README file
- nanoserv - http://pear.si.kz/get/nanoserv-1.1.0.tgz
- PHP 5.1+
In addition to daemons created with the administration UI, modules can define default daemons (a bit like default views in views module). Some default daemons are provided as examples.
Daemon with a stupid HTTP server on port 41000 that echo requested URL.
$ drush daemon http_echo
In a browser, go to: http://localhost:41000/foobar
The daemon returns the text: "You asked for url: /foobar"
Daemon with a HTTP server on port 41001 that fires the drupal menu system and return the result (not "page" themed).
$ drush daemon http_menu
In a browser, go to: http://localhost:41001/node/1
The daemon fires the drupal's menu system on path node/1, and return back the result to the browser, but without calling theme('page', ...).
- hook_daemon_listeners() - Modules can define listeners that can be added to daemons. A listener is a class that is instantiated each time a client connects to the daemon on a specific port, and that handle this connection. Have a look to the default handlers provided with nanoserv: there are simple HTTP, Soap, XML-RPC, SMTP and Syslog handlers.
- hook_daemon_default_daemons() - Modules can define default daemons configurations. They setup which listener will be active in a given daemon, and for each listener on what port and with what protocol (tcp or udp).
- hook_daemon_timeout($tid) - This hook is called when a timer is fired. The argument $tid correspond to the Timer id. If return value is false then the timer is stopped, else the timer will be fired again.
- Allow to activate the fork setting on listeners, so that every accepted connection is handled in a forked child process