Closed (works as designed)
Project:
DataSync
Version:
6.x-1.0-beta2
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
12 Nov 2009 at 14:03 UTC
Updated:
16 Nov 2009 at 15:43 UTC
Because you bootstrap Drupal when starting the deamon, and because it lives as a demon, hook_exit() is never called. I have a limit use case where a module that alter taxonomy uses the hook_exit() to do cleaning tasks.
Because of this module, I need to have this hook ran at each job ends. All you need to do is to put this:
module_invoke_all('exit');
at the right place!
Hook_exit() is rarely used, but it can be for stuff other than statistics computing.
Comments
Comment #1
andrewlevine commentedI don't think it would really be correct to call hook_exit from DataSync by default since we are not exiting the request after each job.
You do have 2 options:
1. Invoke hook_exit in an implementation of hook_datasync_post_jobs which is invoked in datasync_run.php and will be ran after each iteration of spawning jobs.
2. Invoke hooke_exit in an implementation of hook_datasync_phase_completed which is invoked in datasync.job.inc
Although I recommend calling the specific code you want instead of hook_exit() because other code will assume it is at the end of a page request if you call hook_exit
Comment #2
pounardThe fact is my job does not know in advance what modules will react to hook it fires. I can't afford to do compatibility patches for potentially each module installed on the Drupal instance.
I think calling hook_init() and hook_exit() at job init phase and job exit phases is a good idea.
Comment #3
andrewlevine commentedThe reason I can't call hook_init and hook_exit by default is that it would be breaking the Drupal API. These hooks are supposed to be called at the beginning and end of the page request. Several modules depend on these hooks being called once per page request, as specified by the API.
As far as I know, there isn't any reason you couldn't add a phase to your job that invokes module_invoke_all('exit'), right?