File tree 1 file changed +13
-8
lines changed
1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change 12
12
13
13
from auvlog import config
14
14
15
- redis = redis .StrictRedis ()
15
+ redis_client = redis .StrictRedis ()
16
16
17
17
socketS = nanomsg .Socket (nanomsg .SUB )
18
18
socketS .set_string_option (nanomsg .SUB , nanomsg .SUB_SUBSCRIBE , '' )
21
21
socketP = nanomsg .Socket (nanomsg .PUB )
22
22
socketP .bind ("tcp://*:{0}" .format (config .SERVER_PORT ))
23
23
24
+
24
25
def push_to_file (entry ):
25
- try :
26
- f = open (os .path .join (os .environ ['CUAUV_LOG' ], 'current/auvlog.log' ), 'ab' )
27
- f .write (entry + b'\n ' )
28
- except IOError :
29
- print ('Warning: Unable to write log entry to file.' )
26
+ try :
27
+ f = open (os .path .join (os .environ ['CUAUV_LOG' ], 'current/auvlog.log' ), 'ab' )
28
+ f .write (entry + b'\n ' )
29
+ except IOError :
30
+ print ('Warning: Unable to write log entry to file.' , flush = True )
31
+
30
32
31
33
while True :
32
34
res = socketS .recv ()
33
- redis .lpush (config .KEY , res )
34
- redis .ltrim (config .KEY , 0 , int (1e5 ))
35
+ try :
36
+ redis_client .lpush (config .KEY , res )
37
+ redis_client .ltrim (config .KEY , 0 , int (1e5 ))
38
+ except redis .exceptions .ConnectionError :
39
+ print ('Warning: Unable to connect to redis instance' , flush = True )
35
40
push_to_file (res )
36
41
socketP .send (res )
You can’t perform that action at this time.
0 commit comments