diff --git a/dataLogger.py b/dataLogger.py index 00ad18f..15ec300 100644 --- a/dataLogger.py +++ b/dataLogger.py @@ -9,8 +9,6 @@ from pycomm_helper.alarm import AnalogAlarm, bitAlarm import traceback import json import requests -import os -import sys from requests.packages.urllib3.exceptions import InsecureRequestWarning from requests.packages.urllib3.exceptions import InsecurePlatformWarning @@ -319,16 +317,4 @@ def main(): print("Error during loop: {}".format(e)) traceback.print_exc() if __name__ == '__main__': - pid = str(os.getpid()) - pidfile = "/root/datalogger.pid" - - if os.path.isfile(pidfile): - print "%s already exists, exiting" % pidfile - sys.exit() - - try: - file(pidfile, 'w').write(pid) - main() - except IOError: - print("Unable to write the PID to {}. Running the datalogger anyway.".format(pidfile)) - main() + main() diff --git a/datalogger.sh b/datalogger.sh index f2bbf0f..2b3b09d 100755 --- a/datalogger.sh +++ b/datalogger.sh @@ -21,7 +21,7 @@ start() { fi echo 'Starting service…' >&2 local CMD="$SCRIPT &> \"$LOGFILE\" & echo \$!" - su -c "$CMD" $RUNAS > /dev/null + su -c "$CMD" $RUNAS > "$PIDFILE" echo 'Service started' >&2 }