|
|
|
@@ -14,16 +14,16 @@
|
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
*/
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include "autoconfig.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <signal.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
#include <sys/resource.h>
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#endif
|
|
|
|
|
#include "safefcntl.h"
|
|
|
|
|
#include "safeunistd.h"
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
@@ -45,7 +45,9 @@ using namespace std;
|
|
|
|
|
#include "beaglequeue.h"
|
|
|
|
|
#include "recollindex.h"
|
|
|
|
|
#include "fsindexer.h"
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
|
#include "rclionice.h"
|
|
|
|
|
#endif
|
|
|
|
|
#include "execmd.h"
|
|
|
|
|
#include "checkretryfailed.h"
|
|
|
|
|
|
|
|
|
@@ -177,11 +179,13 @@ static void makeIndexerOrExit(RclConfig *config, bool inPlaceReset)
|
|
|
|
|
|
|
|
|
|
void rclIxIonice(const RclConfig *config)
|
|
|
|
|
{
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
|
string clss, classdata;
|
|
|
|
|
if (!config->getConfParam("monioniceclass", clss) || clss.empty())
|
|
|
|
|
clss = "3";
|
|
|
|
|
config->getConfParam("monioniceclassdata", classdata);
|
|
|
|
|
rclionice(clss, classdata);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class MakeListWalkerCB : public FsTreeWalkerCB {
|
|
|
|
@@ -393,8 +397,10 @@ int main(int argc, char **argv)
|
|
|
|
|
// The reexec struct is used by the daemon to shed memory after
|
|
|
|
|
// the initial indexing pass and to restart when the configuration
|
|
|
|
|
// changes
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
|
o_reexec = new ReExec;
|
|
|
|
|
o_reexec->init(argc, argv);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
thisprog = argv[0];
|
|
|
|
|
argc--; argv++;
|
|
|
|
@@ -463,7 +469,9 @@ int main(int argc, char **argv)
|
|
|
|
|
cerr << "Configuration problem: " << reason << endl;
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
|
o_reexec->atexit(cleanup);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
vector<string> nonexist;
|
|
|
|
|
if (!checktopdirs(config, nonexist))
|
|
|
|
@@ -483,7 +491,7 @@ int main(int argc, char **argv)
|
|
|
|
|
if ((op_flags & OPT_E)) {
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
|
string rundir;
|
|
|
|
|
config->getConfParam("idxrundir", rundir);
|
|
|
|
|
if (!rundir.compare("tmp")) {
|
|
|
|
@@ -501,6 +509,7 @@ int main(int argc, char **argv)
|
|
|
|
|
rundir.c_str(), errno));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
bool rezero((op_flags & OPT_z) != 0);
|
|
|
|
|
bool inPlaceReset((op_flags & OPT_Z) != 0);
|
|
|
|
@@ -522,12 +531,13 @@ int main(int argc, char **argv)
|
|
|
|
|
// Log something at LOGINFO to reset the trace file. Else at level
|
|
|
|
|
// 3 it's not even truncated if all docs are up to date.
|
|
|
|
|
LOGINFO(("recollindex: starting up\n"));
|
|
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
|
if (setpriority(PRIO_PROCESS, 0, 20) != 0) {
|
|
|
|
|
LOGINFO(("recollindex: can't setpriority(), errno %d\n", errno));
|
|
|
|
|
}
|
|
|
|
|
// Try to ionice. This does not work on all platforms
|
|
|
|
|
rclIxIonice(config);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (op_flags & (OPT_i|OPT_e)) {
|
|
|
|
|
lockorexit(&pidfile);
|
|
|
|
@@ -596,15 +606,17 @@ int main(int argc, char **argv)
|
|
|
|
|
lockorexit(&pidfile);
|
|
|
|
|
if (!(op_flags&OPT_D)) {
|
|
|
|
|
LOGDEB(("recollindex: daemonizing\n"));
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
|
if (daemon(0,0) != 0) {
|
|
|
|
|
fprintf(stderr, "daemon() failed, errno %d\n", errno);
|
|
|
|
|
LOGERR(("daemon() failed, errno %d\n", errno));
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
// Need to rewrite pid, it changed
|
|
|
|
|
pidfile.write_pid();
|
|
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
|
// Not too sure if I have to redo the nice thing after daemon(),
|
|
|
|
|
// can't hurt anyway (easier than testing on all platforms...)
|
|
|
|
|
if (setpriority(PRIO_PROCESS, 0, 20) != 0) {
|
|
|
|
@@ -612,6 +624,7 @@ int main(int argc, char **argv)
|
|
|
|
|
}
|
|
|
|
|
// Try to ionice. This does not work on all platforms
|
|
|
|
|
rclIxIonice(config);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (sleepsecs > 0) {
|
|
|
|
|
LOGDEB(("recollindex: sleeping %d\n", sleepsecs));
|
|
|
|
@@ -639,6 +652,7 @@ int main(int argc, char **argv)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
deleteZ(confindexer);
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
|
o_reexec->insertArgs(vector<string>(1, "-n"));
|
|
|
|
|
LOGINFO(("recollindex: reexecuting with -n after initial full pass\n"));
|
|
|
|
|
// Note that -n will be inside the reexec when we come
|
|
|
|
@@ -646,6 +660,7 @@ int main(int argc, char **argv)
|
|
|
|
|
// starting a config change exec to ensure that we do a
|
|
|
|
|
// purging pass in this case.
|
|
|
|
|
o_reexec->reexec();
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
if (updater) {
|
|
|
|
|
updater->status.phase = DbIxStatus::DBIXS_MONITOR;
|
|
|
|
|