diff options
author | Lars Wirzenius <liw@liw.fi> | 2017-04-01 17:18:16 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2017-04-01 19:23:06 +0300 |
commit | 2d6a1ead51d7229b2a14d056d02cae9a8c8f642b (patch) | |
tree | 291f3c7e32797e97201120177ec85393d586d9ad | |
parent | 963a6c1bc53e92083815fa94011888fb0a72be79 (diff) | |
download | ick2-2d6a1ead51d7229b2a14d056d02cae9a8c8f642b.tar.gz |
Add a dummy controller implementation
We need _something_ to allow integration tests to be written.
-rwxr-xr-x | controller | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/controller b/controller new file mode 100755 index 0000000..559ff9d --- /dev/null +++ b/controller @@ -0,0 +1,45 @@ +#!/usr/bin/env python2 + + +import os +import random +import sys + +import bottle + + +@bottle.route('/') +def root(): + return 'This is the root' + +@bottle.route('/version') +def version(): + return { 'version': '1.0' } + + +# Command line args. + +pid_file = sys.argv[1] +port_file = sys.argv[2] + + + +log_file = open('log', 'a') +def log(msg): + log_file.write('{} {}\n'.format(os.getpid(), msg)) + log_file.flush() + + +# Write pid to named file. + +with open(pid_file, 'w') as f: + f.write('{}\n'.format(os.getpid())) + + +# Pick a random port and write it to named file. +port = random.randint(1025, 32767) +with open(port_file, 'w') as f: + f.write('{}\n'.format(port)) + + +bottle.run(port=port, quiet=True) |