PHP-FPM Failed on Restart

Discussion in 'General' started by Abel Vieira, Jul 11, 2017.

  1. Abel Vieira

    Abel Vieira New Member

    Hi,

    After a change in a website configuration changing to PHP to "PHP-FPM" (already all others execute with "PHP-FPM"), the php-fpm failed on restart and all other websites go down.

    Code:
    [11-Jul-2017 16:01:02] NOTICE: Reloading in progress ...
    [11-Jul-2017 16:01:02] NOTICE: reloading: execvp("/usr/sbin/php-fpm7.0", {"/usr/sbin/php-fpm7.0", "--nodaemonize", "--fpm-config", "/etc/php/7.0/fpm/php-fpm.conf"})
    [11-Jul-2017 16:01:02] ERROR: [/etc/php/7.0/fpm/pool.d/web188.conf:9] unable to parse value for entry 'pm': invalid process manager (static, dynamic or ondemand)
    [11-Jul-2017 16:01:02] ERROR: Unable to include /etc/php/7.0/fpm/pool.d/web188.conf from /etc/php/7.0/fpm/php-fpm.conf at line 9
    [11-Jul-2017 16:01:02] ERROR: failed to load configuration file '/etc/php/7.0/fpm/php-fpm.conf'
    [11-Jul-2017 16:01:02] ERROR: FPM initialization failed
    
    It's possible introduce, as the apache2 vhost process, if the restart fail for some reason, can rename the conf file to something like ".conf.err" and try restarting again?
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    I wonder how you were able to set a wrong process manager there. Please post line 9 of the file /etc/php/7.0/fpm/pool.d/web188.conf
     
  3. Abel Vieira

    Abel Vieira New Member

    The pool conf file not exist one time that i have all customers down, i change again that website again to "mod-php", and ispconfig unlink the pool config file.

    But i have the datatlog of the change (for security reasons i hide some fields):
    Code:
    Array
    (
        [old] => Array
            (
                [domain_id] => 188
                [sys_userid] => 155
                [sys_groupid] => 155
                [sys_perm_user] => riud
                [sys_perm_group] => ru
                [sys_perm_other] =>
                [server_id] => 5
                [ip_address] => *
                [ipv6_address] =>
                [domain] => hidden.com
                [type] => vhost
                [parent_domain_id] => 0
                [vhost_type] => name
                [document_root] => /home/web188
                [web_folder] =>
                [system_user] => web188
                [system_group] => client154
                [hd_quota] => -1
                [traffic_quota] => -1
                [cgi] => n
                [ssi] => n
                [suexec] => y
                [errordocs] => 1
                [is_subdomainwww] => 1
                [subdomain] => www
                [php] => mod
                [ruby] => n
                [python] => n
                [perl] => n
                [redirect_type] =>
                [redirect_path] =>
                [seo_redirect] =>
                [rewrite_to_https] => n
                [ssl] => y
                [ssl_letsencrypt] => n
                [ssl_state] =>
                [ssl_locality] =>
                [ssl_organisation] =>
                [ssl_organisation_unit] =>
                [ssl_country] =>
                [ssl_domain] => hidden.com
                [ssl_request] => *****
                [ssl_cert] => ******
                [ssl_bundle] => *****
                [ssl_key] => *****
                [ssl_action] =>
                [stats_password] =>
                [stats_type] =>
                [allow_override] => All
                [apache_directives] =>
                [nginx_directives] =>
                [php_fpm_use_socket] => n
                [pm] =>
                [pm_max_children] => 1
                [pm_start_servers] => 1
                [pm_min_spare_servers] => 1
                [pm_max_spare_servers] => 1
                [pm_process_idle_timeout] => 10
                [pm_max_requests] => 0
                [php_open_basedir] => /home/web188/web:/home/web188/private:/home/web188/tmp:/var/www/hidden.com/web:/srv/www/hidden.com/web:/usr/share/php5:/usr/share/php:/tmp:/usr/share/phpmyadmin:/etc/phpmyadmin:/var/lib/phpmyadmin:/dev/random:/dev/urandom
                [custom_php_ini] =>
                [backup_interval] => none
                [backup_copies] => 1
                [backup_excludes] =>
                [active] => y
                [traffic_quota_lock] => n
                [fastcgi_php_version] =>
                [proxy_directives] =>
                [enable_spdy] => n
                [last_quota_notification] =>
                [rewrite_rules] =>
                [added_date] =>
                [added_by] =>
                [directive_snippets_id] => 0
                [enable_pagespeed] => n
                [http_port] => 80
                [https_port] => 443
                [log_retention] => 30
                [folder_directive_snippets] =>
            )
    
        [new] => Array
            (
                [domain_id] => 188
                [sys_userid] => 155
                [sys_groupid] => 155
                [sys_perm_user] => riud
                [sys_perm_group] => ru
                [sys_perm_other] =>
                [server_id] => 5
                [ip_address] => *
                [ipv6_address] =>
                [domain] => hidden.com
                [type] => vhost
                [parent_domain_id] => 0
                [vhost_type] => name
                [document_root] => /home/web188
                [web_folder] =>
                [system_user] => web188
                [system_group] => client154
                [hd_quota] => -1
                [traffic_quota] => -1
                [cgi] => n
                [ssi] => n
                [suexec] => y
                [errordocs] => 1
                [is_subdomainwww] => 1
                [subdomain] => www
                [php] => php-fpm
                [ruby] => n
                [python] => n
                [perl] => n
                [redirect_type] =>
                [redirect_path] =>
                [seo_redirect] =>
                [rewrite_to_https] => n
                [ssl] => y
                [ssl_letsencrypt] => n
                [ssl_state] =>
                [ssl_locality] =>
                [ssl_organisation] =>
                [ssl_organisation_unit] =>
                [ssl_country] =>
                [ssl_domain] => hidden.com
                [ssl_request] => ******
                [ssl_cert] => *****
                [ssl_bundle] => ****
                [ssl_key] => ****
                [ssl_action] =>
                [stats_password] =>
                [stats_type] =>
                [allow_override] => All
                [apache_directives] =>
                [nginx_directives] =>
                [php_fpm_use_socket] => n
                [pm] =>
                [pm_max_children] => 1
                [pm_start_servers] => 1
                [pm_min_spare_servers] => 1
                [pm_max_spare_servers] => 1
                [pm_process_idle_timeout] => 10
                [pm_max_requests] => 0
                [php_open_basedir] => /home/web188/web:/home/web188/private:/home/web188/tmp:/var/www/hidden.com/web:/srv/www/hidden.com/web:/usr/share/php5:/usr/share/php:/tmp:/usr/share/phpmyadmin:/etc/phpmyadmin:/var/lib/phpmyadmin:/dev/random:/dev/urandom
                [custom_php_ini] =>
                [backup_interval] => none
                [backup_copies] => 1
                [backup_excludes] =>
                [active] => y
                [traffic_quota_lock] => n
                [fastcgi_php_version] =>
                [proxy_directives] =>
                [enable_spdy] => n
                [last_quota_notification] =>
                [rewrite_rules] =>
                [added_date] =>
                [added_by] =>
                [directive_snippets_id] => 0
                [enable_pagespeed] => n
                [http_port] => 80
                [https_port] => 443
                [log_retention] => 30
                [folder_directive_snippets] =>
            )
    )
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    I wonder why pm is empty on your server as this field is filled in by default when you use ISPConfig GUI. Maybe you created that site trough the API and did not set that value?
     
  5. Abel Vieira

    Abel Vieira New Member

    The website it's original created by API. The change from "mod-php" to "php-fpm" are done more later in GUI
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    Ok, then you probably missed setting a valid PM with the api.
     
  7. Abel Vieira

    Abel Vieira New Member

    Sure. Thanks for help.

    The file (as example) "server/plugins-available/apache2_plugin.inc.php line 1764" have a verification on apache restart that works very well:
    PHP:
    if($web_config['check_apache_config'] == 'y') {
                
    //* Test if apache starts with the new configuration file
                
    $apache_online_status_before_restart $this->_checkTcp('localhost'80);
                
    $app->log('Apache status is: '.($apache_online_status_before_restart === true'running' 'down'), LOGLEVEL_DEBUG);

                
    $retval $app->services->restartService('httpd''restart'); // $retval['retval'] is 0 on success and > 0 on failure
                
    $app->log('Apache restart return value is: '.$retval['retval'], LOGLEVEL_DEBUG);

                
    // wait a few seconds, before we test the apache status again
                
    $apache_online_status_after_restart false;
                
    sleep(2);
                for(
    $i 0$i 5$i++) {
                    
    $apache_online_status_after_restart $this->_checkTcp('localhost'80);
                    if(
    $apache_online_status_after_restart) break;
                    
    sleep(1);
                }
                
    //* Check if apache restarted successfully if it was online before
                
    $app->log('Apache online status after restart is: '.($apache_online_status_after_restart === true'running' 'down'), LOGLEVEL_DEBUG);
                if(
    $apache_online_status_before_restart && !$apache_online_status_after_restart || $retval['retval'] > 0) {
                    
    $app->log('Apache did not restart after the configuration change for website '.$data['new']['domain'].'. Reverting the configuration. Saved non-working config as '.$vhost_file.'.err'LOGLEVEL_WARN);
                    
    //......
                    
    $app->system->copy($vhost_file$vhost_file.'.err');
                    if(
    is_file($vhost_file.'~')) {
                        
    //* Copy back the last backup file
                        
    $app->system->copy($vhost_file.'~'$vhost_file);
                    } else {
                        
    //* There is no backup file, so we create a empty vhost file with a warning message inside
                        
    $app->system->file_put_contents($vhost_file"# Apache did not start after modifying this vhost file.\n# Please check file $vhost_file.err for syntax errors.");
                    }
                    
    //....
                    
    $app->services->restartService('httpd''restart');
                }
            }
    Suggestion: Can do something similar to php-fpm restarts / pool conf file?
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    Better fix your api script to set all values correctly. Your problem can not be reproduced trough the ISPConfig GUI so adding code to prevent a situation that can't be triggered trough ISPConfig does not make much sense,it adds just bloat to the plugin codes. You can not compare this to the apache config file as the apache config file allows users to add custom config in the apache directives field and therefore, this test code exists to check that custom code. The API is a low-level api, so you as the developer have to take care that you set all values correctly on insert in the same way that the iSPConfig GUI is doing it.
     
  9. Abel Vieira

    Abel Vieira New Member

    Done and working ;)
     

Share This Page