Skip to content

Commit be6abd6

Browse files
committed
Added host and port settings to configuration file
1 parent 7459e5b commit be6abd6

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

sysdweb.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
# - user. for control systemd user units
2525
scope = system
2626

27+
# Can configure listen address host and port. If not present, default values
28+
# will be used. Take note that you can pass this values via args and they
29+
# prevail over this configuration.
30+
#host = 127.0.0.1
31+
#port = 10080
32+
2733
# Some sample entries
2834
[ngx]
2935
title = Nginx

sysdweb/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
def main():
1414
parser = argparse.ArgumentParser()
15-
parser.add_argument('-c', '--config', metavar='value', default=None, help='Custom configuration file path')
16-
parser.add_argument('-l', '--listen', metavar='value', default='127.0.0.1', help='listen address (host or ip), default: 127.0.0.1')
17-
parser.add_argument('-p', '--port', metavar='value', default='10080', help='listen port, default: 10080')
15+
parser.add_argument('-c', '--config', metavar='value', help='Custom configuration file path')
16+
parser.add_argument('-l', '--listen', metavar='value', help='listen address (host or ip), default: 127.0.0.1')
17+
parser.add_argument('-p', '--port', metavar='value', help='listen port, default: 10080')
1818
args = parser.parse_args()
1919

2020
start (args.config, args.listen, args.port)

sysdweb/server.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,8 @@ def start(config_file, host, port):
100100
global config
101101
config = checkConfig(config_file)
102102

103+
if host == None: host = config.get('DEFAULT', 'host', fallback='127.0.0.1')
104+
if port == None: port = config.get('DEFAULT', 'port', fallback='10080')
105+
103106
# Run webserver
104107
run(host=host, port=port)

0 commit comments

Comments
 (0)