Merge branch '162-phase-2-changes' into 'master'
Resolve "Phase 2 changes" Closes #162 See merge request jankstudio/resq!173
This commit is contained in:
commit
4152f00e92
1 changed files with 11 additions and 10 deletions
|
|
@ -7,17 +7,18 @@ import time
|
||||||
import signal
|
import signal
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def sigint_handler(signal, frame):
|
def sigint_handler(signal, frame):
|
||||||
print 'Interrupted'
|
logging.warning('Interrupted')
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
os._exit(0)
|
os._exit(0)
|
||||||
|
|
||||||
|
|
||||||
def on_connect(client, userdata, flags, rc):
|
def on_connect(client, userdata, flags, rc):
|
||||||
print("Connected with result code "+str(rc))
|
logging.info("Connected with result code "+str(rc))
|
||||||
client.subscribe("$SYS/#")
|
client.subscribe("$SYS/#")
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -34,13 +35,13 @@ def getRedis(i):
|
||||||
data = r.brpop("events", 10)
|
data = r.brpop("events", 10)
|
||||||
if data:
|
if data:
|
||||||
info = data[1].split('|')
|
info = data[1].split('|')
|
||||||
print "Channel: " + info[0] + " message: " + info[1]
|
logging.info("Channel: " + info[0] + " message: " + info[1])
|
||||||
client.publish(info[0], info[1])
|
client.publish(info[0], info[1])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def sigint_handler(signal, frame):
|
def sigint_handler(signal, frame):
|
||||||
print 'Interrupted'
|
logging.warning('Interrupted')
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -49,8 +50,6 @@ def main():
|
||||||
client.on_connect = on_connect
|
client.on_connect = on_connect
|
||||||
client.on_publish = on_publish
|
client.on_publish = on_publish
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
client.tls_set(
|
client.tls_set(
|
||||||
"/etc/letsencrypt/live/resqaws.jankstudio.com/fullchain.pem", cert_reqs=ssl.CERT_NONE,
|
"/etc/letsencrypt/live/resqaws.jankstudio.com/fullchain.pem", cert_reqs=ssl.CERT_NONE,
|
||||||
tls_version=ssl.PROTOCOL_TLSv1)
|
tls_version=ssl.PROTOCOL_TLSv1)
|
||||||
|
|
@ -64,7 +63,9 @@ def main():
|
||||||
client.loop_forever()
|
client.loop_forever()
|
||||||
|
|
||||||
|
|
||||||
|
logging.basicConfig(filename='/tmp/mqtt_sender.log', level=logging.INFO)
|
||||||
pid = "/tmp/mqtt_sender.pid"
|
logging.info('Started mqtt_sender')
|
||||||
daemon = Daemonize(app="mqtt_sender", pid=pid, action=main)
|
#pid = "/tmp/mqtt_sender.pid"
|
||||||
daemon.start()
|
#daemon = Daemonize(app="mqtt_sender", pid=pid, action=main)
|
||||||
|
#daemon.start()
|
||||||
|
main()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue