def index(): project = flask.current_app.project ADMIN_LOG_LINE_COUNT = 20 try: last_admin_log = utils.tail(open(project.admin_log_path, 'rb'), ADMIN_LOG_LINE_COUNT) except IOError: last_admin_log = "[Not available]" deployer = project.deployer deployer.refresh() return render_template('index.html', last_admin_log=last_admin_log, config=project.config, deployer=deployer)
def index(): project = flask.current_app.project ADMIN_LOG_LINE_COUNT = 20 try: last_admin_log = utils.tail( open(project.admin_log_path, 'rb'), ADMIN_LOG_LINE_COUNT) except IOError: last_admin_log = "[Not available]" deployer = project.deployer deployer.refresh() return render_template( 'index.html', last_admin_log=last_admin_log, config=project.config, deployer=deployer)
def send_restart_mail(self, fail_kind, restart_count, last_start_s): if not self.config.send_mail_on_restart: return log.info('Sending restart mail') hostname = socket.gethostname() LINE_COUNT = 500 try: last_log = utils.tail(open(self.config.log_file, 'rb'), LINE_COUNT) except IOError: last_log = "[Not available]" subject = ('Synthese {fail_kind} on {hostname} (project: {project}, ' 'restarts: {restart_count})'.format( fail_kind=fail_kind, hostname=hostname, project=self.config.project_name, restart_count=restart_count)) body = ''' Detected Synthese {fail_kind} on {hostname}. It is going to restart. Total restart count: {restart_count}. Seconds since last start: {uptime_s}. Last {line_count} lines of log: {last_log} Have a nice day, The synthese.py wrapper script. '''.format( fail_kind=fail_kind, hostname=hostname, restart_count=restart_count, line_count=LINE_COUNT, last_log=last_log, uptime_s=int(time.time() - last_start_s)) utils.send_mail(self.env.config, self.config.mail_admins, subject, body)