mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-29 15:43:56 +00:00
Cleanup the rhizome database every 30 minutes or so
This commit is contained in:
parent
2ef73884a1
commit
ca8f651b8d
@ -427,7 +427,6 @@ STRUCT(rhizome)
|
||||
ATOM(bool_t, enable, 1, boolean,, "If true, server opens Rhizome database when starting")
|
||||
ATOM(bool_t, fetch, 1, boolean,, "If false, no new bundles will be fetched from peers")
|
||||
ATOM(bool_t, clean_on_open, 0, boolean,, "If true, Rhizome database is cleaned at start of every command")
|
||||
ATOM(bool_t, clean_on_start, 1, boolean,, "If true, Rhizome database is cleaned at start of daemon")
|
||||
STRING(256, datastore_path, "", str_nonempty,, "Path of rhizome storage directory, absolute or relative to instance directory")
|
||||
ATOM(uint64_t, database_size, UINT64_MAX, uint64_scaled,, "Maximum size of database in bytes")
|
||||
ATOM(uint64_t, min_free_space, 100*1024*1024, uint64_scaled,, "Minimum free space to preserve on the disk")
|
||||
|
20
server.c
20
server.c
@ -348,13 +348,21 @@ void server_watchdog(struct sched_ent *alarm)
|
||||
}
|
||||
}
|
||||
|
||||
DEFINE_ALARM(rhizome_open_db);
|
||||
void rhizome_open_db(struct sched_ent *UNUSED(alarm))
|
||||
DEFINE_ALARM(rhizome_clean_db);
|
||||
void rhizome_clean_db(struct sched_ent *alarm)
|
||||
{
|
||||
if (config.rhizome.enable && !rhizome_db){
|
||||
if (!config.rhizome.enable)
|
||||
return;
|
||||
|
||||
time_ms_t now = gettime_ms();
|
||||
if (!rhizome_db){
|
||||
rhizome_opendb();
|
||||
if (config.rhizome.clean_on_start && !config.rhizome.clean_on_open)
|
||||
rhizome_cleanup(NULL);
|
||||
// first clean up 5 minutes after opening
|
||||
RESCHEDULE(alarm, now + 5*60*1000, TIME_MS_NEVER_WILL, TIME_MS_NEVER_WILL);
|
||||
}else{
|
||||
rhizome_cleanup(NULL);
|
||||
// clean up every 30 minutes or so
|
||||
RESCHEDULE(alarm, now + 30*60*1000, TIME_MS_NEVER_WILL, TIME_MS_NEVER_WILL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -389,7 +397,7 @@ void cf_on_config_change()
|
||||
now+config.server.config_reload_interval_ms+100);
|
||||
|
||||
if (config.rhizome.enable){
|
||||
RESCHEDULE(&ALARM_STRUCT(rhizome_open_db), now+100, now+100, TIME_MS_NEVER_WILL);
|
||||
RESCHEDULE(&ALARM_STRUCT(rhizome_clean_db), now+100, now+100, TIME_MS_NEVER_WILL);
|
||||
}else if(rhizome_db){
|
||||
rhizome_close_db();
|
||||
}
|
||||
|
@ -910,7 +910,6 @@ setup_MeshMSAddGrow() {
|
||||
setup_rhizome
|
||||
executeOk_servald config set rhizome.clean_on_open on
|
||||
export SERVALD_ORPHAN_PAYLOAD_PERSIST_MS=0
|
||||
export SERVALD_INVALID_PAYLOAD_PERSIST_MS=0
|
||||
echo "Message1" >file1
|
||||
echo -e "service=MeshMS1\nsender=$SIDB1\nrecipient=$SIDB2" >file1.manifest
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user