Hi all, i am trying to write a plugin that is doing some actions after a server is added to a multiserver setup. In this case it should create all PHP versions for a new server. Due to the module server_module.inc.php there is an event called 'server_insert'. The onInstall() just returns true. The onLoad() just registers the event with $app->plugins->registerEvent('server_insert', $this->plugin_name, 'createPhpVersions'); The function createPhpVersions($event_name, $data) just should do some debug stuff right now and not inserting anything. So i added some $app->log() in LOGLEVEL_DEBUG and, as it doesn't work right now, i'm going to create a tmp file in /tmp and tried to get some output. The plugin is linked in plugins-enabled. But it seems it isn't get called as there are no debug outputs in logs nor any files in /tmp/ that would provide any info. Even in every php log there is no information. I'm really at the end of knowledge right now. Did i miss something? Following the PHP code and yeah it's just pure debug (and yes, debug level for logging is set). For your information: in my config.inc.local.php i have set the array with all needed informations. PHP: <?php class z_create_php_versions_plugin { var $plugin_name = 'z_create_php_versions_plugin'; var $class_name = 'z_create_php_versions_plugin'; var $action = 'insert'; function onInstall() { $tmpfile = tempnam('/tmp'); $filehandle = fopen($tmpfile, "w"); fwrite($filehandle, 'in onInstall()'); fclose($filehandle); return true; } function onLoad() { global $app; $tmpfile = tempnam('/tmp'); $filehandle = fopen($tmpfile, "w"); fwrite($filehandle, 'in onLoad()'); fclose($filehandle); $app->plugins->registerEvent('server_insert', $this->plugin_name, 'createPhpVersions'); } function createPhpVersions($event_name, $data) { global $app, $conf; $tmpfile = tempnam('/tmp'); $filehandle = fopen($tmpfile, "w"); $app->log(var_export($conf, true), LOGLEVEL_DEBUG); $app->log('Insert server_id: ' . $conf["server_id"], LOGLEVEL_DEBUG); fwrite($filehandle, 'Insert server_id: ' . $conf["server_id"]); if (is_array($conf['php_versions_overview'])) { foreach ($conf['php_versions_overview'] as $phpversion => $phpvalues) { $app->log('Installing PHP version: ' . $phpversion, LOGLEVEL_DEBUG); fwrite($filehandle, 'Installing PHP version: ' . $phpversion); $app->log('Example Values: ' . $phpvalues['Name'] . ' - ' . $phpvalues['FPMPathPool'], LOGLEVEL_DEBUG); fwrite($filehandle, 'Example Values: ' . $phpvalues['Name'] . ' - ' . $phpvalues['FPMPathPool']); } } else { $app->log('No valid PHP versions array found in config.inc.local.php or any other config file', LOGLEVEL_DEBUG); fwrite($filehandle, 'No valid PHP versions array found in config.inc.local.php or any other config file'); } fclose($filehandle); } }
There is no server_insert event. The server insert happens at install time of ISPConfig, so that's not an event that is handled by the server.php script as it is not installed yet at that time.
Ok. I'm wondering as it gets announced via $app->plugins->announceEvents. Thougt it would be triggered as soon as the server is inserted into server table. Other Plugins like network_settings_plugin.inc.php and xmpp are using are using this event too. Is there any event i can trigger after a new node is connected to the master server? Thanks in advance
There is currently no event for that. The ISPConfig installer which connects from the slave inserts the data directly without using sys_datalog. To implement such an event, we would have to extend the installer first to write to sys_datalog too on the master and then we can implement an event in the server module which then can get listened to by the plugins.