I have a python daemon built to count the lines of a file once every minute, do some math and calculate the number of lines added in the last minute. The output is a basic csv with the count and a timestamp so that I can latter graph it with another script.
The daemon runs for a period of time, "it seems to be between and hour or two", and then quits. There's no indication as to why.
The basic daemon template is derived from: This post
import os
import subprocess
import time
from daemon import runner
import datetime
inputfilename="test_data"
class App():
    def __init__(self):
        self.stdin_path = '/dev/null'
        self.stdout_path = '/dev/tty'
        self.stderr_path = '/dev/tty'
        self.pidfile_path =  '/tmp/counter.pid'
        self.pidfile_timeout = 5
    def run(self):
        counter1 = 0
        counter_log = 0
        while True:
            count = 0
            output = open("tpm_counter.log", 'a')            
            FILEIN = open(inputfilename, 'rb')
            while 1:
              buffer = FILEIN.read(8192*1024)
              if not buffer: break
              count += buffer.count('\n')
            FILEIN.close(  )
            counter_log =  (count - counter1) * 30
            now = str(datetime.datetime.now())
            counter1 = count
            line = str(counter_log)
            output.write(line)
            output.write(", ")
            output.write(now)
            output.write("\n")
            output.close( )
            # set the sleep time for repeated action here:
            time.sleep(60)
app = App()
daemon_runner = runner.DaemonRunner(app)
daemon_runner.do_action()
Does anyone have any idea why this might be quitting?
 
     
    