Skip to content
This repository has been archived by the owner on May 29, 2023. It is now read-only.

Commit

Permalink
New: configuration file
Browse files Browse the repository at this point in the history
I'm not closing the issue because it still won't necessarily be used---like not
with the default startup script.

Working toward #42
  • Loading branch information
crantila committed Jul 3, 2015
1 parent 3c14322 commit fa0d11d
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
1 change: 1 addition & 0 deletions abbott/__init__.py
Expand Up @@ -10,6 +10,7 @@
define('licence', default=False, type=bool, help='show licence information')
define('license', default=False, type=bool, help='show license information')
define('copyright', default=False, type=bool, help='show copyright information')
define('options_file', default='', type=str, help='optional path to the server configuration file')

from abbott import *
# we must retain this import statement to ensure that all modules will be imported with
Expand Down
11 changes: 10 additions & 1 deletion abbott/__main__.py
Expand Up @@ -97,11 +97,19 @@ def main():
'''

try:
options.parse_command_line()
options.parse_command_line(final=False)
except OptionsError as opt_err:
print(str(opt_err))
return

# see if there's a configuration file for us
if len(options.options_file) > 1:
try:
options.parse_config_file(options.options_file, final=True)
except FileNotFoundError:
print('Could not find the options file "{}"\nQuitting.'.format(options.options_file))
return

# to allow --copyright, --license, and --licence to work identically
if options.license or options.copyright:
options.licence = True
Expand Down Expand Up @@ -145,6 +153,7 @@ def main():
if options.debug:
print('Listening on {}'.format(options.server_name))

# prepare settings for the HTTPServer
settings = {'debug': options.debug,
'compress_response': not options.debug,
}
Expand Down
51 changes: 51 additions & 0 deletions scripts/server_configuration.py
@@ -0,0 +1,51 @@
#
# Options Configuration File
#
# This file is part of the "Abbott" Web server for the Cantus API.
# Abbott Copyright (C) 2015 Christopher Antila

# The octothorpe character ("hashtag") begins a comment. Every other line is a possible
# configuration option for Abbott. The file is parsed as Python.


## General ----------------------------------------------------------------------------------------

# "debug" starts the server in a debugging-friendly mode (with more logging information). Because
# this exposes potentially sensitive information to remote clients, you should leave it False in
# deployment.
debug = False


## URLs -------------------------------------------------------------------------------------------

# "scheme" is either "http" or "https" as appropriate for links on Abbott itself.
scheme = 'http'

# "hostname" is the fully-qualified domain name as appropriate for links on Abbott itself.
hostname = 'localhost'

# "port" is the port on which Abbott should operate
port = 8888


## Logging ----------------------------------------------------------------------------------------

# Level of messages to write to the log (debug, info, warning, error, none).
if debug:
logging = 'debug'
else:
logging = 'warning'

# send log output to stderr (colourized if possible). This is the default if "log_file_prefix" is
# not configured.
#log_to_stderr = True

# path prefix for log files. Note that if you are running multiple Tornado processes, this must be
# different for each of them (e.g., include the port number)
log_file_prefix = '/var/log/abbott/server.log'

# number of log files to keep
#log_file_num_backups = 10

# "max size of log files before rollover
#log_file_max_size = 100000000

0 comments on commit fa0d11d

Please sign in to comment.