forked from Mirrors/privacore-open-source-search-engine
Added cmd-line command for preparing and switching to new site-default-page-temp generation
This commit is contained in:
25
Parms.cpp
25
Parms.cpp
@ -36,6 +36,7 @@
|
||||
#include "Collectiondb.h"
|
||||
#include "Doledb.h"
|
||||
#include "GbDns.h"
|
||||
#include "SiteMedianPageTemperatureRegistry.h"
|
||||
#include <set>
|
||||
#include <fstream>
|
||||
|
||||
@ -711,6 +712,18 @@ static bool CommandMergeTagdb(const char *rec) {
|
||||
}
|
||||
|
||||
|
||||
static bool CommandSiteDefaultPageTemperature(const char *rec) {
|
||||
const char *subCommand = getDataFromParmRec(rec);
|
||||
log(LOG_DEBUG,"admin: stedeftemp: subCommand=%s'", subCommand);
|
||||
if(strcmp(subCommand,"prepare")==0)
|
||||
return g_smptr.prepare_new_generation();
|
||||
if(strcmp(subCommand,"switch")==0) {
|
||||
g_smptr.switch_generation();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool CommandDiskPageCacheOff(const char *rec) {
|
||||
g_process.resetPageCaches();
|
||||
return true;
|
||||
@ -5210,6 +5223,18 @@ void Parms::init ( ) {
|
||||
m->m_obj = OBJ_CONF;
|
||||
m++;
|
||||
|
||||
m->m_title = "sitedeftemp";
|
||||
m->m_desc = "prepares or switches to a new site-default-page-temperature file generation.";
|
||||
m->m_cgi = "sitedeftemp";
|
||||
m->m_type = TYPE_CMD;
|
||||
m->m_func = CommandSiteDefaultPageTemperature;
|
||||
m->m_cast = true;
|
||||
m->m_group = false;
|
||||
m->m_flags = PF_HIDDEN | PF_NOSAVE;
|
||||
m->m_page = PAGE_MASTER;
|
||||
m->m_obj = OBJ_CONF;
|
||||
m++;
|
||||
|
||||
m->m_title = "disk page cache off";
|
||||
m->m_desc = "Disable all disk page caches to save mem for "
|
||||
"tmp cluster. Run "
|
||||
|
34
main.cpp
34
main.cpp
@ -1132,6 +1132,33 @@ int main2 ( int argc , char *argv[] ) {
|
||||
g_collectiondb.reset();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(strcmp(cmd, "sitedeftemp") == 0) {
|
||||
int32_t h1=-1;
|
||||
int32_t h2=-1;
|
||||
if(cmdarg + 2 < argc) {
|
||||
int n = sscanf(argv[cmdarg+2],"%d-%d",&h1,&h2);
|
||||
if(n<1) {
|
||||
fprintf(stderr,"Unrecognized host range: '%s'\n", argv[cmdarg+2]);
|
||||
printHelp();
|
||||
return 1;
|
||||
} else if(h2<h1) {
|
||||
fprintf(stderr,"host2<host1 in host range: '%s'\n", argv[cmdarg+2]);
|
||||
printHelp();
|
||||
return 1;
|
||||
}
|
||||
if(n==1)
|
||||
h2 = h1;
|
||||
}
|
||||
if(strcmp(argv[cmdarg+1],"prepare")==0)
|
||||
return doCmd("sitedeftemp=prepare", h1, "master", true, false, h2);
|
||||
else if(strcmp(argv[cmdarg+1],"switch")==0)
|
||||
return doCmd("sitedeftemp=switch", h1, "master", true, false, h2);
|
||||
else {
|
||||
printHelp();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if(strcmp(cmd, "dumpcsv") == 0) {
|
||||
g_conf.m_readOnlyMode = true; //we don't need write access
|
||||
@ -1902,6 +1929,13 @@ static void printHelp() {
|
||||
"\trobots.txt.cache:\n"
|
||||
"\t\tdump rtc <url>\n"
|
||||
"\n"
|
||||
"sitedeftemp\n"
|
||||
"\tPrepares or switches to a new site-default-page-temperature generation.\n"
|
||||
"\tsitedeftemp prepare\n"
|
||||
"\t\tPrepares a new site-default-page-temperature generation\n"
|
||||
"\tsitedeftemp switch\n"
|
||||
"\t\tSwitches to a new site-default-page-temperature generation previously prepared with 'sitedeftemp prepare'\n"
|
||||
"\n"
|
||||
);
|
||||
|
||||
//word-wrap to screen width, if known
|
||||
|
Reference in New Issue
Block a user