summaryrefslogtreecommitdiffstats
path: root/tupkg/server
diff options
context:
space:
mode:
Diffstat (limited to 'tupkg/server')
-rwxr-xr-xtupkg/server/tupkgs21
-rw-r--r--tupkg/server/tupkgs.conf3
2 files changed, 22 insertions, 2 deletions
diff --git a/tupkg/server/tupkgs b/tupkg/server/tupkgs
index a1d343c9..63abaea0 100755
--- a/tupkg/server/tupkgs
+++ b/tupkg/server/tupkgs
@@ -160,7 +160,7 @@ class ClientSocket(threading.Thread):
self.readFiles()
class ServerSocket(threading.Thread):
- def __init__(self, db, port=1034, maxqueue=5, **other):
+ def __init__(self, db, port, maxqueue, **other):
threading.Thread.__init__(self, *other)
self.running = 1
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@@ -199,10 +199,20 @@ def usage(name):
print " -c, --config Specify an alternate config file (default " + CONFIGFILE + ")"
sys.exit(2)
+def getDefaultConfig():
+ confdict = {}
+ confdict['port'] = 1034
+ confdict['maxqueue'] = 5
+
+ return confdict
+
+
def main(argv=None):
if argv is None:
argv = sys.argv
+ confdict = getDefaultConfig()
+
try:
optlist, args = getopt.getopt(argv[1:], "c:", ["config="])
except getopt.GetoptError:
@@ -222,6 +232,13 @@ def main(argv=None):
running = 1
+ print "Parsing config file"
+ if config.has_section('tupkgs'):
+ if config.has_option('tupkgs', 'port'):
+ confdict['port'] = config.getint('tupkgs', 'port')
+ if config.has_option('tupkgs', 'maxqueue'):
+ confdict['maxqueue'] = config.getint('tupkgs', 'maxqueue')
+
print "Connecting to MySQL database"
dbconn = MySQLdb.connect(host=config.get('mysql', 'host'),
user=config.get('mysql', 'username'),
@@ -229,7 +246,7 @@ def main(argv=None):
db=config.get('mysql', 'db'))
print "Starting ServerSocket"
- servsock = ServerSocket(dbconn)
+ servsock = ServerSocket(dbconn, confdict['port'], confdict['maxqueue'])
servsock.start()
try:
diff --git a/tupkg/server/tupkgs.conf b/tupkg/server/tupkgs.conf
index 94b6fad2..ab31db95 100644
--- a/tupkg/server/tupkgs.conf
+++ b/tupkg/server/tupkgs.conf
@@ -1,3 +1,6 @@
+[tupkgs]
+port = 1034
+
[mysql]
username = aur
password = aur