Changeset 573b810 in mod_gnutls
- Timestamp:
- Jan 9, 2020, 2:47:21 AM (3 years ago)
- Branches:
- asyncio, main, master, proxy-ticket
- Children:
- 7e10018
- Parents:
- 278381d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
test/mgstest/services.py
r278381d r573b810 17 17 import errno 18 18 import os 19 import os.path20 19 import signal 21 20 import subprocess … … 23 22 24 23 from contextlib import contextmanager 24 from pathlib import Path 25 25 from time import sleep 26 26 … … 37 37 self.forking = forking 38 38 # condition: start service if the function returns true 39 if condition: 40 self.condition = condition 41 else: 42 self.condition = lambda: True 39 self.condition = condition or (lambda: True) 43 40 44 41 # child process for non-forking services … … 46 43 # Forking processes like apache2 require a PID file for 47 44 # tracking. The process must delete its PID file when exiting. 48 self.pidfile = pidfile45 self.pidfile = Path(pidfile) if pidfile else None 49 46 if not self.pidfile and self.forking: 50 47 raise ValueError('Forking service must provide PID file!') … … 86 83 # Read PID file before actually sending the stop signal 87 84 if self.pidfile: 88 if not os.path.exists(self.pidfile):85 if not self.pidfile.exists(): 89 86 print(f'Skipping stop of {self.stop_command}, no PID file!') 90 87 # Presumably the process isn't running, ignore. 91 88 return 92 with open(self.pidfile, 'r') as file: 93 self.pid = int(file.read()) 89 self.pid = int(self.pidfile.read_text()) 94 90 if self.stop_command: 95 91 print(f'Stopping: {self.stop_command}') … … 170 166 171 167 def __init__(self, config, env=None, pidfile=None, check=None): 172 self.config = os.path.realpath(config)168 self.config = Path(config).resolve() 173 169 base_cmd = [self.apache2, '-f', str(self.config), '-k'] 174 170 if not check: … … 183 179 184 180 def config_exists(self): 185 return os.path.isfile(self.config)181 return self.config.is_file() 186 182 187 183 def pidfile_check(self): 188 184 """Default check method for ApacheService, waits for the PID file to 189 185 be present.""" 190 return os.path.exists(self.pidfile)186 return self.pidfile.is_file()
Note: See TracChangeset
for help on using the changeset viewer.