]> granicus.if.org Git - php/commitdiff
- Fixed #52692 (Added '-t/--test' to php-fpm to check and validate FPM conf file)
authorJérôme Loyet <fat@php.net>
Thu, 11 Nov 2010 23:27:15 +0000 (23:27 +0000)
committerJérôme Loyet <fat@php.net>
Thu, 11 Nov 2010 23:27:15 +0000 (23:27 +0000)
sapi/fpm/fpm/fpm.h
sapi/fpm/fpm/fpm_conf.c
sapi/fpm/fpm/fpm_main.c
sapi/fpm/php-fpm.8.in

index ba439044810014a90a671778095b59d7d5d9d15b..626afbe0e9e64a4563163c46f4d789b6666d1241 100644 (file)
@@ -23,6 +23,7 @@ struct fpm_globals_s {
        int listening_socket; /* for this child */
        int max_requests; /* for this child */
        int is_child;
+       int test_conf;
 };
 
 extern struct fpm_globals_s fpm_globals;
index 54c04a4aac618ae73ea45c24fa9dd130284b5167..296f669b64ae440226d4bdf575d739fd46b8f0c3 100644 (file)
@@ -1028,13 +1028,20 @@ int fpm_conf_init_main() /* {{{ */
                return -1;
        }
 
-       if (free) efree(filename);
-
        if (0 > fpm_conf_post_process()) {
                zlog(ZLOG_ERROR, "failed to post process the configuration");
+               if (free) efree(filename);
                return -1;
        }
 
+       if (fpm_globals.test_conf) {
+               zlog(ZLOG_NOTICE, "configuration file %s test is successful\n", filename);
+               if (free) efree(filename);
+               return -1;
+       }
+
+       if (free) efree(filename);
+
        if (0 > fpm_cleanup_add(FPM_CLEANUP_ALL, fpm_conf_cleanup, 0)) {
                return -1;
        }
index 81c494c4a3d80135779210781b2dae89fb3e1878..8086a7bdfd7b1813dc1e13af486f3fff43dbb869 100644 (file)
@@ -152,6 +152,7 @@ static const opt_struct OPTIONS[] = {
        {'?', 0, "usage"},/* help alias (both '?' and 'usage') */
        {'v', 0, "version"},
        {'y', 1, "fpm-config"},
+       {'t', 0, "test"},
        {'-', 0, NULL} /* end of args */
 };
 
@@ -957,7 +958,7 @@ static void php_cgi_usage(char *argv0)
                prog = "php";
        }
 
-       php_printf(     "Usage: %s [-n] [-e] [-h] [-i] [-m] [-v] [-c <file>] [-d foo[=bar]] [-y <file>]\n"
+       php_printf(     "Usage: %s [-n] [-e] [-h] [-i] [-m] [-v] [-t] [-c <file>] [-d foo[=bar]] [-y <file>]\n"
                                "  -c <path>|<file> Look for php.ini file in this directory\n"
                                "  -n               No php.ini file will be used\n"
                                "  -d foo[=bar]     Define INI entry foo with value 'bar'\n"
@@ -967,7 +968,8 @@ static void php_cgi_usage(char *argv0)
                                "  -m               Show compiled in modules\n"
                                "  -v               Version number\n"
                                "  -y, --fpm-config <file>\n"
-                               "                   Specify alternative path to FastCGI process manager config file.\n",
+                               "                   Specify alternative path to FastCGI process manager config file.\n"
+                               "  -t, --test       Test FPM configuration and exit\n",
                                prog);
 }
 /* }}} */
@@ -1625,6 +1627,10 @@ int main(int argc, char *argv[])
                                CG(compiler_options) |= ZEND_COMPILE_EXTENDED_INFO;
                                break;
 
+                       case 't': 
+                               fpm_globals.test_conf = 1;
+                               break;
+
                        case 'm': /* list compiled in modules */
                                cgi_sapi_module.startup(&cgi_sapi_module);
                                php_output_activate(TSRMLS_C);
index e91aff8605e6bb37ebcd316620b951dcbab19c0b..1aa8b62b95efc9937502d74133f4fbbca29a55cf 100644 (file)
@@ -86,6 +86,13 @@ Version number
 Specify alternative path to FastCGI process manager configuration file (the default is @php_fpm_sysconfdir@/php-fpm.conf)
 .TP
 .PD 0
+.B \-\-test
+.TP
+.PD 1
+.B \-t
+Test FPM configuration file and exit
+.TP
+.PD 0
 .B \-\-zend\-extension \fIfile\fP
 .TP
 .PD 1