2021-06-12 07:09:26 +00:00
|
|
|
# Titan Robotics Team 2022: Superscript Script
|
|
|
|
# Written by Arthur Lu, Jacob Levine, and Dev Singh
|
|
|
|
# Notes:
|
|
|
|
# setup:
|
|
|
|
|
2021-08-17 21:02:08 +00:00
|
|
|
__version__ = "1.0.0"
|
2021-06-12 07:09:26 +00:00
|
|
|
|
|
|
|
# changelog should be viewed using print(analysis.__changelog__)
|
|
|
|
__changelog__ = """changelog:
|
2021-08-17 21:02:08 +00:00
|
|
|
1.0.0:
|
|
|
|
- superscript now runs in PEP 3143 compliant well behaved daemon on Linux systems
|
|
|
|
- linux superscript daemon has integrated websocket output to monitor progress/status remotely
|
2021-09-21 04:43:32 +00:00
|
|
|
- linux daemon now sends stderr to errorlog.log
|
2021-08-18 00:43:00 +00:00
|
|
|
- added verbose option to linux superscript to allow for interactive output
|
2021-08-18 03:26:47 +00:00
|
|
|
- moved pymongo import to superscript.py
|
2021-08-19 00:34:42 +00:00
|
|
|
- added profile option to linux superscript to profile runtime of script
|
2021-09-21 04:43:32 +00:00
|
|
|
- reduced memory usage slightly by consolidating the unwrapped input data
|
|
|
|
- added debug option, which performs one loop of analysis and dumps results to local files
|
2021-08-27 23:39:48 +00:00
|
|
|
- added event and time delay options to config
|
|
|
|
- event delay pauses loop until even listener recieves an update
|
|
|
|
- time delay pauses loop until the time specified has elapsed since the BEGINNING of previous loop
|
2021-09-23 07:10:01 +00:00
|
|
|
- added options to pull config information from database (reatins option to use local config file)
|
|
|
|
- config-preference option selects between prioritizing local config and prioritizing database config
|
|
|
|
- synchronize-config option selects whether to update the non prioritized config with the prioritized one
|
|
|
|
- divided config options between persistent ones (keys), and variable ones (everything else)
|
2022-02-19 06:19:13 +00:00
|
|
|
- generalized behavior of various core components by collecting loose functions in several dependencies into classes
|
|
|
|
- module.py contains classes, each one represents a single data analysis routine
|
|
|
|
- config.py contains the Configuration class, which stores the configuration information and abstracts the getter methods
|
2021-08-17 21:02:08 +00:00
|
|
|
0.9.3:
|
|
|
|
- improved data loading performance by removing redundant PyMongo client creation (120s to 14s)
|
|
|
|
- passed singular instance of PyMongo client as standin for apikey parameter in all data.py functions
|
2021-08-13 21:57:03 +00:00
|
|
|
0.9.2:
|
|
|
|
- removed unessasary imports from data
|
|
|
|
- minor changes to interface
|
2021-06-13 00:49:04 +00:00
|
|
|
0.9.1:
|
|
|
|
- fixed bugs in configuration item loading exception handling
|
2021-06-12 07:16:11 +00:00
|
|
|
0.9.0:
|
|
|
|
- moved printing and logging related functions to interface.py (changelog will stay in this file)
|
|
|
|
- changed function return files for load_config and save_config to standard C values (0 for success, 1 for error)
|
|
|
|
- added local variables for config location
|
2021-06-12 23:57:16 +00:00
|
|
|
- moved dataset getting and setting functions to dataset.py (changelog will stay in this file)
|
|
|
|
- moved matchloop, metricloop, pitloop and helper functions (simplestats) to processing.py
|
2021-06-12 07:09:26 +00:00
|
|
|
0.8.6:
|
|
|
|
- added proper main function
|
|
|
|
0.8.5:
|
|
|
|
- added more gradeful KeyboardInterrupt exiting
|
|
|
|
- redirected stderr to errorlog.txt
|
|
|
|
0.8.4:
|
|
|
|
- added better error message for missing config.json
|
|
|
|
- added automatic config.json creation
|
|
|
|
- added splash text with version and system info
|
|
|
|
0.8.3:
|
|
|
|
- updated matchloop with new regression format (requires tra_analysis 3.x)
|
|
|
|
0.8.2:
|
|
|
|
- readded while true to main function
|
|
|
|
- added more thread config options
|
|
|
|
0.8.1:
|
|
|
|
- optimized matchloop further by bypassing GIL
|
|
|
|
0.8.0:
|
|
|
|
- added multithreading to matchloop
|
|
|
|
- tweaked user log
|
|
|
|
0.7.0:
|
|
|
|
- finished implementing main function
|
|
|
|
0.6.2:
|
|
|
|
- integrated get_team_rankings.py as get_team_metrics() function
|
|
|
|
- integrated visualize_pit.py as graph_pit_histogram() function
|
|
|
|
0.6.1:
|
|
|
|
- bug fixes with analysis.Metric() calls
|
|
|
|
- modified metric functions to use config.json defined default values
|
|
|
|
0.6.0:
|
|
|
|
- removed main function
|
|
|
|
- changed load_config function
|
|
|
|
- added save_config function
|
|
|
|
- added load_match function
|
|
|
|
- renamed simpleloop to matchloop
|
|
|
|
- moved simplestats function inside matchloop
|
|
|
|
- renamed load_metrics to load_metric
|
|
|
|
- renamed metricsloop to metricloop
|
|
|
|
- split push to database functions amon push_match, push_metric, push_pit
|
|
|
|
- moved
|
|
|
|
0.5.2:
|
|
|
|
- made changes due to refactoring of analysis
|
|
|
|
0.5.1:
|
|
|
|
- text fixes
|
|
|
|
- removed matplotlib requirement
|
|
|
|
0.5.0:
|
|
|
|
- improved user interface
|
|
|
|
0.4.2:
|
|
|
|
- removed unessasary code
|
|
|
|
0.4.1:
|
|
|
|
- fixed bug where X range for regression was determined before sanitization
|
|
|
|
- better sanitized data
|
|
|
|
0.4.0:
|
|
|
|
- fixed spelling issue in __changelog__
|
|
|
|
- addressed nan bug in regression
|
|
|
|
- fixed errors on line 335 with metrics calling incorrect key "glicko2"
|
|
|
|
- fixed errors in metrics computing
|
|
|
|
0.3.0:
|
|
|
|
- added analysis to pit data
|
|
|
|
0.2.1:
|
|
|
|
- minor stability patches
|
|
|
|
- implemented db syncing for timestamps
|
|
|
|
- fixed bugs
|
|
|
|
0.2.0:
|
|
|
|
- finalized testing and small fixes
|
|
|
|
0.1.4:
|
|
|
|
- finished metrics implement, trueskill is bugged
|
|
|
|
0.1.3:
|
|
|
|
- working
|
|
|
|
0.1.2:
|
|
|
|
- started implement of metrics
|
|
|
|
0.1.1:
|
|
|
|
- cleaned up imports
|
|
|
|
0.1.0:
|
|
|
|
- tested working, can push to database
|
|
|
|
0.0.9:
|
|
|
|
- tested working
|
|
|
|
- prints out stats for the time being, will push to database later
|
|
|
|
0.0.8:
|
|
|
|
- added data import
|
|
|
|
- removed tba import
|
|
|
|
- finished main method
|
|
|
|
0.0.7:
|
|
|
|
- added load_config
|
|
|
|
- optimized simpleloop for readibility
|
|
|
|
- added __all__ entries
|
|
|
|
- added simplestats engine
|
|
|
|
- pending testing
|
|
|
|
0.0.6:
|
|
|
|
- fixes
|
|
|
|
0.0.5:
|
|
|
|
- imported pickle
|
|
|
|
- created custom database object
|
|
|
|
0.0.4:
|
|
|
|
- fixed simpleloop to actually return a vector
|
|
|
|
0.0.3:
|
|
|
|
- added metricsloop which is unfinished
|
|
|
|
0.0.2:
|
|
|
|
- added simpleloop which is untested until data is provided
|
|
|
|
0.0.1:
|
|
|
|
- created script
|
|
|
|
- added analysis, numba, numpy imports
|
|
|
|
"""
|
|
|
|
|
|
|
|
__author__ = (
|
|
|
|
"Arthur Lu <learthurgo@gmail.com>",
|
|
|
|
"Jacob Levine <jlevine@imsa.edu>",
|
|
|
|
)
|
|
|
|
|
|
|
|
# imports:
|
|
|
|
|
2022-02-19 06:19:13 +00:00
|
|
|
import os, sys, time
|
|
|
|
import pymongo # soon to be deprecated
|
2021-10-12 22:16:34 +00:00
|
|
|
import traceback
|
2021-06-12 23:57:16 +00:00
|
|
|
import warnings
|
2022-02-19 06:19:13 +00:00
|
|
|
from config import Configuration, ConfigurationError
|
2022-03-28 20:47:46 +00:00
|
|
|
from data import get_previous_time, set_current_time, check_new_database_matches, clear_metrics
|
2022-02-19 08:52:49 +00:00
|
|
|
from interface import Logger
|
2021-10-28 20:40:56 +00:00
|
|
|
from module import Match, Metric, Pit
|
2022-02-19 22:58:58 +00:00
|
|
|
import zmq
|
2021-06-12 07:09:26 +00:00
|
|
|
|
|
|
|
config_path = "config.json"
|
|
|
|
|
2022-02-19 08:52:49 +00:00
|
|
|
def main(logger, verbose, profile, debug, socket_send = None):
|
2021-08-17 21:02:08 +00:00
|
|
|
|
2021-09-23 07:10:01 +00:00
|
|
|
def close_all():
|
|
|
|
if "client" in locals():
|
|
|
|
client.close()
|
2021-08-17 21:02:08 +00:00
|
|
|
|
2021-08-19 20:58:35 +00:00
|
|
|
warnings.filterwarnings("ignore")
|
2021-06-12 07:09:26 +00:00
|
|
|
|
2022-02-19 08:52:49 +00:00
|
|
|
logger.splash(__version__)
|
2021-06-12 23:57:16 +00:00
|
|
|
|
2021-10-28 20:40:56 +00:00
|
|
|
modules = {"match": Match, "metric": Metric, "pit": Pit}
|
|
|
|
|
2021-06-12 23:57:16 +00:00
|
|
|
while True:
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
loop_start = time.time()
|
|
|
|
|
2022-02-19 08:52:49 +00:00
|
|
|
logger.info("current time: " + str(loop_start))
|
2022-02-19 22:58:58 +00:00
|
|
|
socket_send("current time: " + str(loop_start))
|
2021-06-12 23:57:16 +00:00
|
|
|
|
2022-02-19 06:19:13 +00:00
|
|
|
config = Configuration(config_path)
|
2021-06-12 23:57:16 +00:00
|
|
|
|
2022-02-19 08:52:49 +00:00
|
|
|
logger.info("found and loaded config at <" + config_path + ">")
|
2022-02-19 22:58:58 +00:00
|
|
|
socket_send("found and loaded config at <" + config_path + ">")
|
2021-09-23 07:10:01 +00:00
|
|
|
|
2022-02-19 06:19:13 +00:00
|
|
|
apikey, tbakey = config.database, config.tba
|
2021-11-06 00:04:11 +00:00
|
|
|
|
2022-02-19 08:52:49 +00:00
|
|
|
logger.info("found and loaded database and tba keys")
|
2022-02-19 22:58:58 +00:00
|
|
|
socket_send("found and loaded database and tba keys")
|
2021-06-12 23:57:16 +00:00
|
|
|
|
2021-08-17 21:02:08 +00:00
|
|
|
client = pymongo.MongoClient(apikey)
|
|
|
|
|
2022-02-19 08:52:49 +00:00
|
|
|
logger.info("established connection to database")
|
2022-02-19 22:58:58 +00:00
|
|
|
socket_send("established connection to database")
|
2022-02-19 08:52:49 +00:00
|
|
|
|
2022-02-04 03:06:09 +00:00
|
|
|
previous_time = get_previous_time(client)
|
2021-06-12 23:57:16 +00:00
|
|
|
|
2022-02-19 08:52:49 +00:00
|
|
|
logger.info("analysis backtimed to: " + str(previous_time))
|
2022-02-19 22:58:58 +00:00
|
|
|
socket_send("analysis backtimed to: " + str(previous_time))
|
2022-02-19 08:52:49 +00:00
|
|
|
|
|
|
|
config.resolve_config_conflicts(logger, client)
|
2022-02-19 06:19:13 +00:00
|
|
|
|
|
|
|
config_modules, competition = config.modules, config.competition
|
2021-10-28 20:40:56 +00:00
|
|
|
for m in config_modules:
|
|
|
|
if m in modules:
|
|
|
|
start = time.time()
|
2022-02-04 03:06:09 +00:00
|
|
|
current_module = modules[m](config_modules[m], client, tbakey, previous_time, competition)
|
2021-10-28 20:40:56 +00:00
|
|
|
valid = current_module.validate_config()
|
|
|
|
if not valid:
|
|
|
|
continue
|
2022-02-19 06:19:13 +00:00
|
|
|
current_module.run()
|
2022-02-19 08:52:49 +00:00
|
|
|
logger.info(m + " module finished in " + str(time.time() - start) + " seconds")
|
2022-02-19 22:58:58 +00:00
|
|
|
socket_send(m + " module finished in " + str(time.time() - start) + " seconds")
|
2021-10-28 21:12:28 +00:00
|
|
|
if debug:
|
2022-02-19 08:52:49 +00:00
|
|
|
logger.save_module_to_file(m, current_module.data, current_module.results) # logging flag check done in logger
|
2021-06-12 23:57:16 +00:00
|
|
|
|
2021-09-23 07:10:01 +00:00
|
|
|
set_current_time(client, loop_start)
|
|
|
|
close_all()
|
2021-08-18 22:35:42 +00:00
|
|
|
|
2022-02-19 08:52:49 +00:00
|
|
|
logger.info("closed threads and database client")
|
|
|
|
logger.info("finished all tasks in " + str(time.time() - loop_start) + " seconds, looping")
|
2022-02-19 22:58:58 +00:00
|
|
|
socket_send("closed threads and database client")
|
|
|
|
socket_send("finished all tasks in " + str(time.time() - loop_start) + " seconds, looping")
|
2021-06-12 23:57:16 +00:00
|
|
|
|
2021-09-23 07:10:01 +00:00
|
|
|
if profile:
|
2022-02-19 23:29:58 +00:00
|
|
|
return 0
|
2021-06-12 23:57:16 +00:00
|
|
|
|
2022-02-19 08:52:49 +00:00
|
|
|
if debug:
|
2022-02-19 23:29:58 +00:00
|
|
|
return 0
|
2022-02-19 08:52:49 +00:00
|
|
|
|
2021-10-12 22:16:34 +00:00
|
|
|
event_delay = config["variable"]["event-delay"]
|
2021-10-10 06:15:22 +00:00
|
|
|
if event_delay:
|
2022-02-19 08:52:49 +00:00
|
|
|
logger.info("loop delayed until database returns new matches")
|
2022-02-19 22:58:58 +00:00
|
|
|
socket_send("loop delayed until database returns new matches")
|
2021-10-10 06:15:22 +00:00
|
|
|
new_match = False
|
|
|
|
while not new_match:
|
|
|
|
time.sleep(1)
|
|
|
|
new_match = check_new_database_matches(client, competition)
|
2022-02-19 08:52:49 +00:00
|
|
|
logger.info("database returned new matches")
|
2022-02-19 22:58:58 +00:00
|
|
|
socket_send("database returned new matches")
|
2021-10-10 06:15:22 +00:00
|
|
|
else:
|
2021-10-12 22:16:34 +00:00
|
|
|
loop_delay = float(config["variable"]["loop-delay"])
|
2021-10-10 06:15:22 +00:00
|
|
|
remaining_time = loop_delay - (time.time() - loop_start)
|
|
|
|
if remaining_time > 0:
|
2022-02-19 08:52:49 +00:00
|
|
|
logger.info("loop delayed by " + str(remaining_time) + " seconds")
|
2022-02-19 22:58:58 +00:00
|
|
|
socket_send("loop delayed by " + str(remaining_time) + " seconds")
|
2021-10-10 06:15:22 +00:00
|
|
|
time.sleep(remaining_time)
|
2021-08-27 23:39:48 +00:00
|
|
|
|
2021-06-12 23:57:16 +00:00
|
|
|
except KeyboardInterrupt:
|
2021-09-23 07:10:01 +00:00
|
|
|
close_all()
|
2022-02-19 22:58:58 +00:00
|
|
|
logger.info("detected KeyboardInterrupt, exiting")
|
|
|
|
socket_send("detected KeyboardInterrupt, exiting")
|
2022-02-19 23:29:58 +00:00
|
|
|
return 0
|
2021-09-23 07:10:01 +00:00
|
|
|
|
2021-11-06 00:04:11 +00:00
|
|
|
except ConfigurationError as e:
|
2022-02-19 22:58:58 +00:00
|
|
|
str_e = "".join(traceback.format_exception(e))
|
2022-02-19 08:52:49 +00:00
|
|
|
logger.error("encountered a configuration error: " + str(e))
|
2022-02-19 22:58:58 +00:00
|
|
|
logger.error(str_e)
|
|
|
|
socket_send("encountered a configuration error: " + str(e))
|
|
|
|
socket_send(str_e)
|
2021-11-06 00:04:11 +00:00
|
|
|
close_all()
|
2022-02-19 23:29:58 +00:00
|
|
|
return 1
|
2021-11-06 00:04:11 +00:00
|
|
|
|
2021-06-12 23:57:16 +00:00
|
|
|
except Exception as e:
|
2022-02-19 22:58:58 +00:00
|
|
|
str_e = "".join(traceback.format_exception(e))
|
2022-02-19 08:52:49 +00:00
|
|
|
logger.error("encountered an exception while running")
|
2022-02-19 22:58:58 +00:00
|
|
|
logger.error(str_e)
|
|
|
|
socket_send("encountered an exception while running")
|
|
|
|
socket_send(str_e)
|
2021-09-23 07:10:01 +00:00
|
|
|
close_all()
|
2022-02-19 23:29:58 +00:00
|
|
|
return 1
|
2021-06-12 23:57:16 +00:00
|
|
|
|
2022-02-19 08:52:49 +00:00
|
|
|
def start(pid_path, verbose, profile, debug):
|
2021-08-19 00:34:42 +00:00
|
|
|
|
|
|
|
if profile:
|
|
|
|
|
2022-02-19 22:58:58 +00:00
|
|
|
def send(msg):
|
|
|
|
pass
|
|
|
|
|
2022-02-19 08:52:49 +00:00
|
|
|
logger = Logger(verbose, profile, debug)
|
2021-08-19 00:34:42 +00:00
|
|
|
|
|
|
|
import cProfile, pstats, io
|
|
|
|
profile = cProfile.Profile()
|
|
|
|
profile.enable()
|
2022-02-19 22:58:58 +00:00
|
|
|
exit_code = main(logger, verbose, profile, debug, socket_send = send)
|
2021-08-19 00:34:42 +00:00
|
|
|
profile.disable()
|
|
|
|
f = open("profile.txt", 'w+')
|
|
|
|
ps = pstats.Stats(profile, stream = f).sort_stats('cumtime')
|
|
|
|
ps.print_stats()
|
2021-10-12 22:16:34 +00:00
|
|
|
sys.exit(exit_code)
|
2021-08-19 00:34:42 +00:00
|
|
|
|
|
|
|
elif verbose:
|
2021-08-18 22:35:42 +00:00
|
|
|
|
2022-02-19 22:58:58 +00:00
|
|
|
def send(msg):
|
|
|
|
pass
|
|
|
|
|
2022-02-19 08:52:49 +00:00
|
|
|
logger = Logger(verbose, profile, debug)
|
|
|
|
|
2022-02-19 22:58:58 +00:00
|
|
|
exit_code = main(logger, verbose, profile, debug, socket_send = send)
|
2021-10-12 22:16:34 +00:00
|
|
|
sys.exit(exit_code)
|
2021-08-19 00:34:42 +00:00
|
|
|
|
2021-09-21 04:43:32 +00:00
|
|
|
elif debug:
|
|
|
|
|
2022-02-19 22:58:58 +00:00
|
|
|
def send(msg):
|
|
|
|
pass
|
|
|
|
|
2022-02-19 08:52:49 +00:00
|
|
|
logger = Logger(verbose, profile, debug)
|
|
|
|
|
2022-02-19 22:58:58 +00:00
|
|
|
exit_code = main(logger, verbose, profile, debug, socket_send = send)
|
2021-10-12 22:16:34 +00:00
|
|
|
sys.exit(exit_code)
|
2021-09-21 04:43:32 +00:00
|
|
|
|
2021-08-19 00:34:42 +00:00
|
|
|
else:
|
2022-02-19 08:52:49 +00:00
|
|
|
|
|
|
|
logfile = "logfile.log"
|
|
|
|
|
|
|
|
f = open(logfile, 'w+')
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
e = open('errorlog.log', 'w+')
|
2021-08-18 22:35:42 +00:00
|
|
|
with daemon.DaemonContext(
|
2022-02-19 08:52:49 +00:00
|
|
|
working_directory = os.getcwd(),
|
|
|
|
pidfile = pidfile.TimeoutPIDLockFile(pid_path),
|
|
|
|
stderr = e
|
2021-08-18 22:35:42 +00:00
|
|
|
):
|
|
|
|
|
2022-02-19 22:58:58 +00:00
|
|
|
context = zmq.Context()
|
|
|
|
socket = context.socket(zmq.PUB)
|
|
|
|
socket.bind("tcp://*:5678")
|
|
|
|
socket.send(b'status')
|
|
|
|
|
|
|
|
def send(msg):
|
|
|
|
socket.send(bytes("status: " + msg, "utf-8"))
|
|
|
|
|
2022-02-19 08:52:49 +00:00
|
|
|
logger = Logger(verbose, profile, debug, file = logfile)
|
2021-08-18 22:35:42 +00:00
|
|
|
|
2022-02-19 22:58:58 +00:00
|
|
|
exit_code = main(logger, verbose, profile, debug, socket_send = send)
|
2021-08-18 22:35:42 +00:00
|
|
|
|
2022-02-19 22:58:58 +00:00
|
|
|
socket.close()
|
2021-10-14 22:52:15 +00:00
|
|
|
f.close()
|
2022-02-19 22:58:58 +00:00
|
|
|
|
2021-10-16 20:28:57 +00:00
|
|
|
sys.exit(exit_code)
|
2021-08-17 21:02:08 +00:00
|
|
|
|
|
|
|
def stop(pid_path):
|
|
|
|
try:
|
|
|
|
pf = open(pid_path, 'r')
|
|
|
|
pid = int(pf.read().strip())
|
|
|
|
pf.close()
|
|
|
|
except IOError:
|
|
|
|
sys.stderr.write("pidfile at <" + pid_path + "> does not exist. Daemon not running?\n")
|
|
|
|
return
|
|
|
|
|
|
|
|
try:
|
|
|
|
while True:
|
|
|
|
os.kill(pid, SIGTERM)
|
|
|
|
time.sleep(0.01)
|
|
|
|
except OSError as err:
|
|
|
|
err = str(err)
|
|
|
|
if err.find("No such process") > 0:
|
|
|
|
if os.path.exists(pid_path):
|
|
|
|
os.remove(pid_path)
|
|
|
|
else:
|
2022-02-19 08:52:49 +00:00
|
|
|
traceback.print_exc(file = sys.stderr)
|
2021-08-17 21:02:08 +00:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
def restart(pid_path):
|
|
|
|
stop(pid_path)
|
2022-02-19 08:52:49 +00:00
|
|
|
start(pid_path, False, False, False)
|
2021-08-17 21:02:08 +00:00
|
|
|
|
2021-06-12 07:09:26 +00:00
|
|
|
if __name__ == "__main__":
|
2021-08-17 21:02:08 +00:00
|
|
|
|
2021-06-12 23:57:16 +00:00
|
|
|
if sys.platform.startswith("win"):
|
2021-08-18 22:35:42 +00:00
|
|
|
start(None, verbose = True)
|
2021-08-17 21:02:08 +00:00
|
|
|
|
|
|
|
else:
|
2021-08-17 21:17:40 +00:00
|
|
|
import daemon
|
|
|
|
from daemon import pidfile
|
|
|
|
from signal import SIGTERM
|
2021-08-17 21:02:08 +00:00
|
|
|
pid_path = "tra-daemon.pid"
|
|
|
|
if len(sys.argv) == 2:
|
|
|
|
if 'start' == sys.argv[1]:
|
2022-02-19 08:52:49 +00:00
|
|
|
start(pid_path, False, False, False)
|
2021-08-17 21:02:08 +00:00
|
|
|
elif 'stop' == sys.argv[1]:
|
|
|
|
stop(pid_path)
|
|
|
|
elif 'restart' == sys.argv[1]:
|
|
|
|
restart(pid_path)
|
2021-08-18 00:43:00 +00:00
|
|
|
elif 'verbose' == sys.argv[1]:
|
2022-02-19 08:52:49 +00:00
|
|
|
start(None, True, False, False)
|
2021-08-19 00:34:42 +00:00
|
|
|
elif 'profile' == sys.argv[1]:
|
2022-02-19 08:52:49 +00:00
|
|
|
start(None, False, True, False)
|
2021-09-21 04:43:32 +00:00
|
|
|
elif 'debug' == sys.argv[1]:
|
2022-02-19 08:52:49 +00:00
|
|
|
start(None, False, False, True)
|
2021-08-17 21:02:08 +00:00
|
|
|
else:
|
2021-09-21 23:36:13 +00:00
|
|
|
print("usage: %s start|stop|restart|verbose|profile|debug" % sys.argv[0])
|
2021-08-17 21:02:08 +00:00
|
|
|
sys.exit(2)
|
|
|
|
sys.exit(0)
|
|
|
|
else:
|
2021-09-21 23:36:13 +00:00
|
|
|
print("usage: %s start|stop|restart|verbose|profile|debug" % sys.argv[0])
|
2021-08-17 21:02:08 +00:00
|
|
|
sys.exit(2)
|