mirror of
https://github.com/OPSnet/hermes.git
synced 2026-01-16 20:04:33 -05:00
21 lines
506 B
Python
21 lines
506 B
Python
#! /usr/bin/env python3
|
|
|
|
import os
|
|
from hermes import run_hermes
|
|
from hermes.hermes import HERMES_DIR
|
|
|
|
PID = str(os.getpid())
|
|
os.makedirs(HERMES_DIR, exist_ok=True)
|
|
PIDFILE = os.path.join(HERMES_DIR, "hermes.pid")
|
|
|
|
if __name__ == "__main__":
|
|
if os.path.isfile(PIDFILE):
|
|
print("{} already exists, exiting".format(PIDFILE))
|
|
raise SystemExit
|
|
with open(PIDFILE, 'w') as open_pidfile:
|
|
open_pidfile.write(PID)
|
|
try:
|
|
run_hermes()
|
|
finally:
|
|
os.unlink(PIDFILE)
|