@@ -402,7 +402,8 @@ def generate_apache_config(options):
402
402
mount_point = mount_point , directory = directory ,
403
403
filename = filename ), file = fp )
404
404
405
- print (APACHE_ALIAS_DOCUMENTATION % options , file = fp )
405
+ if options ['enable_docs' ]:
406
+ print (APACHE_ALIAS_DOCUMENTATION % options , file = fp )
406
407
407
408
if options ['error_documents' ]:
408
409
for status , document in options ['error_documents' ]:
@@ -781,9 +782,15 @@ def generate_control_scripts(options):
781
782
os .chmod (path , 0o755 )
782
783
783
784
path = os .path .join (options ['server_root' ], 'envvars' )
784
- with open (path , 'w' ) as fp :
785
- if options ['envvars_script' ]:
786
- print (APACHE_ENVVARS_FILE .lstrip () % options , file = fp )
785
+
786
+ if options ['envvars_script' ]:
787
+ with open (path , 'w' ) as fp :
788
+ if options ['envvars_script' ]:
789
+ print (APACHE_ENVVARS_FILE .lstrip () % options , file = fp )
790
+
791
+ elif not os .path .isfile (path ):
792
+ with open (path , 'w' ) as fp :
793
+ pass
787
794
788
795
def check_percentage (option , opt_str , value , parser ):
789
796
if value is not None and value < 0 or value > 1 :
@@ -1055,17 +1062,17 @@ def check_percentage(option, opt_str, value, parser):
1055
1062
'be made available at the /__wsgi__/docs sub URL.' ),
1056
1063
)
1057
1064
1058
- def cmd_setup_server (params , usage = None ):
1065
+ def cmd_setup_server (params ):
1059
1066
formatter = optparse .IndentedHelpFormatter ()
1060
1067
formatter .set_long_opt_delimiter (' ' )
1061
1068
1062
- usage = usage or '%prog setup-server script [options]'
1069
+ usage = '%prog setup-server script [options]'
1063
1070
parser = optparse .OptionParser (usage = usage , option_list = option_list ,
1064
1071
formatter = formatter )
1065
1072
1066
1073
(options , args ) = parser .parse_args (params )
1067
1074
1068
- return _cmd_setup_server (args , vars (options ))
1075
+ _cmd_setup_server ('setup-server' , args , vars (options ))
1069
1076
1070
1077
def _mpm_module_defines (modules_directory ):
1071
1078
result = []
@@ -1076,7 +1083,7 @@ def _mpm_module_defines(modules_directory):
1076
1083
result .append ('-DWSGI_MPM_%s_MODULE' % name .upper ())
1077
1084
return result
1078
1085
1079
- def _cmd_setup_server (args , options ):
1086
+ def _cmd_setup_server (command , args , options ):
1080
1087
options ['mod_wsgi_so' ] = where ()
1081
1088
1082
1089
options ['working_directory' ] = options ['working_directory' ] or os .getcwd ()
@@ -1326,29 +1333,44 @@ def _cmd_setup_server(args, options):
1326
1333
generate_apache_config (options )
1327
1334
generate_control_scripts (options )
1328
1335
1329
- print ('Server URL :' , options ['url' ])
1336
+ print ('Server URL :' , options ['url' ])
1330
1337
1331
1338
if options ['server_status' ]:
1332
- print ('Server Status :' , '%sserver-status' % options ['url' ])
1339
+ print ('Server Status :' , '%sserver-status' % options ['url' ])
1333
1340
1334
- print ('Server Root :' , options ['server_root' ])
1335
- print ('Server Conf :' , options ['httpd_conf' ])
1341
+ print ('Server Root :' , options ['server_root' ])
1342
+ print ('Server Conf :' , options ['httpd_conf' ])
1336
1343
1337
- print ('Error Log :' , options ['error_log' ])
1344
+ print ('Error Log File :' , options ['error_log' ])
1338
1345
1339
1346
if options ['access_log' ]:
1340
- print ('Access Log :' , os .path .join (options ['log_directory' ],
1341
- 'access_log' ))
1347
+ print ('Access Log File :' , os .path .join (options ['log_directory' ],
1348
+ 'access_log' ))
1349
+
1350
+ if options ['envvars_script' ]:
1351
+ print ('Environ Variables :' , options ['envvars_script' ])
1352
+
1353
+ if command == 'setup-server' :
1354
+ if not options ['envvars_script' ]:
1355
+ print ('Environ Variables :' , options ['server_root' ] + '/envvars' )
1356
+ print ('Control Script :' , options ['server_root' ] + '/apachectl' )
1342
1357
1343
1358
return options
1344
1359
1345
1360
def cmd_start_server (params ):
1361
+ formatter = optparse .IndentedHelpFormatter ()
1362
+ formatter .set_long_opt_delimiter (' ' )
1363
+
1346
1364
usage = '%prog start-server script [options]'
1365
+ parser = optparse .OptionParser (usage = usage , option_list = option_list ,
1366
+ formatter = formatter )
1367
+
1368
+ (options , args ) = parser .parse_args (params )
1347
1369
1348
- options = cmd_setup_server ( params , usage )
1370
+ config = _cmd_setup_server ( 'start-server' , args , vars ( options ) )
1349
1371
1350
- executable = os .path .join (options ['server_root' ], 'apachectl' )
1351
- name = executable .ljust (len (options ['process_name' ]))
1372
+ executable = os .path .join (config ['server_root' ], 'apachectl' )
1373
+ name = executable .ljust (len (config ['process_name' ]))
1352
1374
os .execl (executable , name , 'start' , '-DNO_DETACH' )
1353
1375
1354
1376
def cmd_install_module (params ):
0 commit comments