@@ -154,13 +154,17 @@ def _set_redis_options(cls):
154154 Updates the default slips options based on the -s param,
155155 writes the new configs to cls._conf_file
156156 """
157+ # to fix redis.exceptions.ResponseError MISCONF Redis is
158+ # configured to save RDB snapshots
159+ # configure redis to stop writing to dump.rdb when an error
160+ # occurs without throwing errors in slips
157161 cls ._options = {
158162 "daemonize" : "yes" ,
159163 "stop-writes-on-bgsave-error" : "no" ,
160164 "save" : '""' ,
161165 "appendonly" : "no" ,
162166 }
163-
167+ # -s for saving the db
164168 if "-s" not in sys .argv :
165169 return
166170
@@ -188,6 +192,8 @@ def _set_redis_options(cls):
188192 @classmethod
189193 def _read_configuration (cls ):
190194 conf = ConfigParser ()
195+ # Should we delete the previously stored data in the DB when we start?
196+ # By default False. Meaning we don't DELETE the DB by default.
191197 cls .deletePrevdb : bool = conf .delete_prev_db ()
192198 cls .disabled_detections : List [str ] = conf .disabled_detections ()
193199 cls .width = conf .get_tw_width_as_float ()
@@ -227,6 +233,11 @@ def init_redis_server(cls) -> Tuple[bool, str]:
227233 if not connected :
228234 return False , err
229235
236+ # these are the cases that we DO NOT flush the db when we
237+ # connect to it, because we need to use it
238+ # -d means Read an analysed file (rdb) from disk.
239+ # -S stop daemon
240+ # -cb clears the blocking chain
230241 if (
231242 cls .deletePrevdb
232243 and not (
@@ -237,6 +248,7 @@ def init_redis_server(cls) -> Tuple[bool, str]:
237248 # when stopping the daemon, don't flush bc we need to get
238249 # the PIDS to close slips files
239250 cls .r .flushdb ()
251+ cls .r .delete (cls .constants .ZEEK_FILES )
240252
241253 # Set the memory limits of the output buffer,
242254 # For normal clients: no limits
@@ -245,12 +257,6 @@ def init_redis_server(cls) -> Tuple[bool, str]:
245257 cls .change_redis_limits (cls .r )
246258 cls .change_redis_limits (cls .rcache )
247259
248- # to fix redis.exceptions.ResponseError MISCONF Redis is
249- # configured to save RDB snapshots
250- # configure redis to stop writing to dump.rdb when an error
251- # occurs without throwing errors in slips
252- # Even if the DB is not deleted. We need to delete some temp data
253- cls .r .delete (cls .constants .ZEEK_FILES )
254260 return True , ""
255261 except RuntimeError as err :
256262 return False , str (err )
0 commit comments