2014-12-18 18:50:47 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2014, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
2015-01-21 20:56:25 +00:00
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
2014-12-18 18:50:47 +00:00
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*
|
|
|
|
*/
|
2015-01-21 20:56:25 +00:00
|
|
|
|
2014-07-31 00:35:19 +00:00
|
|
|
#include <boost/thread.hpp>
|
|
|
|
|
2014-12-03 23:14:02 +00:00
|
|
|
#include <osquery/core.h>
|
2015-03-21 17:14:57 +00:00
|
|
|
|
2015-03-22 21:58:00 +00:00
|
|
|
#include "osquery/dispatcher/scheduler.h"
|
2014-07-31 00:35:19 +00:00
|
|
|
|
2015-02-06 17:42:03 +00:00
|
|
|
const std::string kWatcherWorkerName = "osqueryd: worker";
|
2015-01-21 20:56:25 +00:00
|
|
|
|
2014-08-30 11:06:21 +00:00
|
|
|
int main(int argc, char* argv[]) {
|
2015-03-03 23:03:14 +00:00
|
|
|
osquery::Initializer runner(argc, argv, osquery::OSQUERY_TOOL_DAEMON);
|
2014-07-31 00:35:19 +00:00
|
|
|
|
2015-03-03 23:03:14 +00:00
|
|
|
if (!runner.isWorker()) {
|
|
|
|
runner.initDaemon();
|
2014-10-27 18:55:28 +00:00
|
|
|
}
|
|
|
|
|
2015-03-13 15:11:08 +00:00
|
|
|
// When a watchdog is used, the current daemon will fork/exec into a worker.
|
|
|
|
// In either case the watcher may start optionally loaded extensions.
|
|
|
|
runner.initWorkerWatcher(kWatcherWorkerName);
|
2015-01-26 08:02:02 +00:00
|
|
|
|
2015-03-03 23:03:14 +00:00
|
|
|
// Start osquery work.
|
|
|
|
runner.start();
|
2014-07-31 00:35:19 +00:00
|
|
|
|
2015-02-06 17:42:03 +00:00
|
|
|
// Begin the schedule runloop.
|
2015-03-21 17:14:57 +00:00
|
|
|
osquery::startScheduler();
|
2014-07-31 00:35:19 +00:00
|
|
|
|
2015-02-01 08:35:44 +00:00
|
|
|
// Finally shutdown.
|
2015-03-03 23:03:14 +00:00
|
|
|
runner.shutdown();
|
2014-09-23 01:35:12 +00:00
|
|
|
|
2014-07-31 00:35:19 +00:00
|
|
|
return 0;
|
|
|
|
}
|