Changeset 1467 for trunk/server/common/oursrc/hacron
- Timestamp:
- Feb 13, 2010, 5:36:36 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/common/oursrc/hacron/hacron
r1466 r1467 1 1 #!/usr/bin/env python 2 from __future__ import with_statement 2 3 import glob 3 4 import logging.handlers … … 29 30 self.errno = errno 30 31 self.msg = msg 32 logger.error(msg) 31 33 32 34 class HaLogHandler(logging.Handler): … … 80 82 81 83 def _remove(dest): 84 if not path.exists(dest) and not path.islink(dest): 85 logger.info('Tried to remove nonexistant path %s' % dest) 86 return True 87 82 88 try: 83 89 if path.isdir(dest): … … 128 134 else: 129 135 cmd = ['service', 'crond', 'reload'] 130 subprocess.check_call(cmd) 136 try: 137 subprocess.check_call(cmd) 138 except OSError, e: 139 raise HacronError(OCF_ERR_GENERIC, 'Cron restart exited with return code %d' % e.errno) 140 else: 141 logger.info('Restarted crond') 131 142 132 143 def start_cron(args, options): … … 155 166 logger.info('Created slave dummy directory %s' % crondir) 156 167 try: 157 _restart_crond( )168 _restart_crond(args, options) 158 169 except OSError, e: 159 logger.error('Cron restart exited with return code %d' % e.errno) 160 return OCF_ERR_GENERIC 161 else: 162 logger.info('Restarted crond') 170 return e.errno 163 171 return OCF_SUCCESS 164 172 … … 175 183 # TODO: should we do something else here? 176 184 try: 177 _restart_crond( )185 _restart_crond(args, options) 178 186 except OSError, e: 179 logger.error('Cron restart exited with return code %d' % e.errno) 180 return OCF_ERR_GENERIC 181 else: 182 logger.info('Restarted crond') 187 return e.errno 183 188 return OCF_SUCCESS 184 189 … … 276 281 277 282 def main(): 278 usage_str = """usage: % %prog [-s server] [-c cronroot] [-d] cmd283 usage_str = """usage: %prog [-s server] [-c cronroot] [-d] cmd 279 284 280 285 Script for starting and stopping cron in a multiserver environment. … … 320 325 _set_globals(args, options) 321 326 except HacronError, e: 322 logger.error(e.msg)323 327 return e.errno 324 328
Note: See TracChangeset
for help on using the changeset viewer.