Move main.py to a scripts directory and wrap in standard options parsing
This commit is contained in:
2 changed files with 35 additions and 8 deletions
@@ -14,7 +14,9 @@ See the License for the specific language governing permissions and
limitations under the License.
"""
import sys
import structlog
import twisted
CONFIGURED_LOGGING = False
@@ -30,6 +32,7 @@ def configure():
CONFIGURED_LOGGING = True
twisted.python.log.startLogging(sys.stderr)
structlog.configure(
context_class=dict,
cache_logger_on_first_use=True)
40
main.py → teeth_agent/scripts/teeth-agent.py
Normal file → Executable file
40
main.py → teeth_agent/scripts/teeth-agent.py
Normal file → Executable file
@@ -1,5 +1,4 @@
#!/usr/bin/env python
"""
Copyright 2013 Rackspace, Inc.
@@ -16,19 +15,44 @@ See the License for the specific language governing permissions and
limitations under the License.
"""
import os
import sys
import twisted
from os.path import dirname
sys.path.append(dirname(dirname(dirname(os.path.realpath(__file__)))))
from twisted.python import usage
from twisted.internet import reactor
import structlog
from teeth_agent.logging import configure as configureLogging
from teeth_agent.agent import StandbyAgent
if __name__ == "__main__":
class Options(usage.Options):
synopsis = """%s [options]
"""% (
os.path.basename(sys.argv[0]),)
optParameters = [["mode", "m", "standbye", "Mode to run Agent in, standbye or decom."]]
def run():
if len(sys.argv) == 1:
sys.argv.append("--help")
config = Options()
try:
config.parseOptions()
except usage.error, ue:
raise SystemExit("%s: %s" % (sys.argv[0], ue))
configureLogging()
structlog.twisted.plainJSONStdOutLogger
twisted.python.log.startLogging(sys.stderr)
agent = StandbyAgent([['localhost', 8081]])
agent.start()
if config['mode'] == "standbye":
agent = StandbyAgent([['localhost', 8081]])
agent.start()
else:
raise SystemExit("Invalid mode")
reactor.run()
if __name__ == "__main__":
run()
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.