forked from zookatron/sublime-collaboration
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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:])) |