diff --git a/config.yaml.example b/config.yaml.example index 35445cb..50b9a1e 100644 --- a/config.yaml.example +++ b/config.yaml.example @@ -17,3 +17,13 @@ irc: channel: "#srobo-comp-ops" enable: false +# Redis server configuration +# The redis server is run by compd +# so don't change these unless you know what you are doing +redis: + host: localhost + port: 10056 + db: 0 + # Okay, you can change this one + server: /usr/local/bin/redis-server + diff --git a/src/compd.py b/src/compd.py index 2e18fd2..155a07b 100644 --- a/src/compd.py +++ b/src/compd.py @@ -15,6 +15,7 @@ import sys import control_socket import control_irc +import redis_process from twisted.internet import reactor, task GIT_VERSION = check_output(('git', 'describe', '--always')).strip() @@ -36,5 +37,10 @@ def print_message(): control_socket.install_control_handler() control_irc.install_irc_handler() +def got_redis(): + print 'Redis is le running' + +redis_process.run_redis_server(got_redis) + reactor.run() diff --git a/src/redis_process.py b/src/redis_process.py new file mode 100644 index 0000000..5419cf5 --- /dev/null +++ b/src/redis_process.py @@ -0,0 +1,25 @@ +from twisted.internet import reactor, protocol + +import sys +import config + +class RedisDataReceiver(protocol.ProcessProtocol): + def __init__(self, on_started): + self.on_started = on_started + + def outReceived(self, data): + print >>sys.stderr, data, + if 'now ready to accept connections' in data: + self.on_started() + + def errReceived(self, data): + print >>sys.stderr, data, + +def run_redis_server(on_started): + print >>sys.stderr, "Starting Redis server..." + server = config.redis['server'] + reactor.spawnProcess(RedisDataReceiver(on_started), + server, + args = [server, 'redis.conf'], + path = '../redis/') +