Skip to content

Commit

Permalink
Create run_server.py
Browse files Browse the repository at this point in the history
Just a simple starter for server outside of ST2.
  • Loading branch information
Grigory Bakunov committed Jan 29, 2013
1 parent a4164f8 commit 14429e4
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions run_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env python
import sys
import collab

def main(argv):
if len(argv) == 1:
if ':' not in argv[0]:
sys.stderr.write("please provide `host:port' to bind or just `host:' for default port\n")
return -2
else:
host, port = argv[0].split(':', 1)
elif len(argv) == 2:
host,port = [x.strip() for x in argv]
elif len(argv) > 2:
sys.stderr.write("use `host:port' arguments\n")
return -3
else:
host, port = '', ''

if host == '':
host = '0.0.0.0'
if port == '':
port = 6633
try:
sys.stderr.write('Starting at ' + host +':' + str(port) + '...')
server = collab.server.CollabServer({'host':host, 'port': int(port)})
sys.stderr.write(' started.\n')
server.run_forever()
except KeyboardInterrupt:
print("^C received, server stopped")
return -1

if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))

0 comments on commit 14429e4

Please sign in to comment.