From 820465828ec4d1e4d7e5c50218df56063f29396b Mon Sep 17 00:00:00 2001 From: Roel Date: Mon, 21 Apr 2014 11:57:16 +0200 Subject: [PATCH] began to integrate server into main.py --- README.md | 2 +- main.py | 24 +++++++++++------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 9ad493a..d13acaa 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Copy the whole filesystem to the USB-Drive: `$ mount --bind / /tmp/cproot` -`$ tar -C /tmp/cproot -cvf - . | tar -C /mnt/sda1 -xf` +`$ tar -C /tmp/cproot -cvf - . | tar -C /mnt/sda1 -xf -` `$ umount /tmp/cproot` diff --git a/main.py b/main.py index 635f14b..375cae3 100755 --- a/main.py +++ b/main.py @@ -33,6 +33,10 @@ class Meshenger: a.daemon = True a.start() + s = threading.Thread(target=self.serve) + s.daemon = True + s.start() + except (KeyboardInterrupt, SystemExit): print 'exiting discovery thread' d.join() @@ -100,19 +104,12 @@ class Meshenger: time.sleep(1) def serve(self): - - # try: - # t = threading.Thread(target=BorderCheckWebserver, args=(self, )) - # t.daemon = True - # t.start() - # time.sleep(2) - # except (KeyboardInterrupt, SystemExit): - # t.join() - # sys.exit() - - a = '' - # serves both the index and the messages on the node over http - # plus manages the client-side web interface + """ + Initialize the server + """ + print 'Serving' + import meshenger_serve + meshenger_serve.main() def build_index(self): """ @@ -165,6 +162,7 @@ class Meshenger: hasj = hashlib.md5(ip).hexdigest() nodepath = os.path.join(os.path.abspath('nodes/'), hasj) if not os.path.exists(nodepath): + os.mkdir('nodes') os.mkdir(nodepath) return nodepath