forked from Isilon/isilon_data_insights_connector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
isi_data_insights_d.py
executable file
·57 lines (45 loc) · 1.87 KB
/
isi_data_insights_d.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python
import sys
from isi_data_insights_config import parse_cli, \
configure_args_via_file, process_pid_file_arg, \
configure_logging_via_cli, configure_via_cli, \
configure_via_file
from isi_data_insights_daemon import IsiDataInsightsDaemon
def main():
args = parse_cli()
# load the config file if one is provided, then set the "required"
# parameters of the CLI args with config file parameters (if possible)
config_file = configure_args_via_file(args)
# validate the pid_file arg and get the full path to it.
pid_file_path = process_pid_file_arg(args.pid_file, args.action)
daemon = IsiDataInsightsDaemon(pidfile=pid_file_path)
# before we do the long process of configuring, lets make sure we have
# a valid pid to do a stop or restart with
if (args.action == "restart" or args.action == "stop") \
and daemon.pid is None:
print >> sys.stderr, "Cannot " + args.action + " daemon, " \
"invalid pid in file: " + str(pid_file_path)
sys.exit(1)
if args.action == "start" \
or args.action == "debug" \
or args.action == "restart":
configure_logging_via_cli(args)
if config_file is not None:
configure_via_file(daemon, args, config_file)
else:
configure_via_cli(daemon, args)
if args.action == "start":
daemon.start()
elif args.action == "restart":
print "Restarting daemon with pid " + str(daemon.pid)
daemon.restart()
else:
daemon.run()
elif args.action == "stop":
print "Stopping daemon with pid " + str(daemon.pid)
daemon.stop()
else:
print >> sys.stderr, "Invalid action arg: '%s', must be one of "\
"'start', 'stop', or 'restart'." % args.action
if __name__ == "__main__":
main()