{"action":"created","comment":{"url":"https://api.github.com/repos/facebook/osquery/pulls/comments/25823019","id":25823019,"diff_hunk":"@@ -51,28 +54,59 @@ enum osqueryTool {\n   OSQUERY_EXTENSION,\n };\n \n-/**\n- * @brief Sets up various aspects of osquery execution state.\n- *\n- * osquery needs a few things to happen as soon as the executable begins\n- * executing. initOsquery takes care of setting up the relevant parameters.\n- * initOsquery should be called in an executable's `main()` function.\n- *\n- * @param argc the number of elements in argv\n- * @param argv the command-line arguments passed to `main()`\n- */\n-void initOsquery(int argc, char* argv[], int tool = OSQUERY_TOOL_TEST);\n-\n-/**\n- * @brief Sets up a process as a osquery daemon.\n- */\n-void initOsqueryDaemon();\n-\n-/**\n- * @brief Turns of various aspects of osquery such as event loops.\n- *\n- */\n-void shutdownOsquery();\n+class Initializer {\n+ public:\n+  /**\n+   * @brief Sets up various aspects of osquery execution state.\n+   *\n+   * osquery needs a few things to happen as soon as the executable begins\n+   * executing. initOsquery takes care of setting up the relevant parameters.\n+   * initOsquery should be called in an executable's `main()` function.\n+   *\n+   * @param argc the number of elements in argv\n+   * @param argv the command-line arguments passed to `main()`\n+   */\n+  Initializer(int argc, char* argv[], int tool = OSQUERY_TOOL_TEST);\n+\n+  /**\n+   * @brief Sets up the process as an osquery daemon.\n+   *\n+   * A daemon has additional constraints, it can use a process mutext, check\n+   * for sane/non-default configurations, etc.\n+   */\n+  void initDaemon();\n+\n+  /**\n+   * @brief Daemon tools may want to continually spawn worker processes\n+   * and monitor their utilization.\n+   *\n+   * A daemon may call initWorkerWatcher to begin watching child daemon\n+   * processes until it-itself is unscheduled. The basic guarentee is that only\n+   * workers will return from the function.\n+   *\n+   * The worker-watcher will implement performance bounds on CPU utilization\n+   * and memory, as well as check for zombie/defunct workers and respawn them\n+   * if appropriate. The appropriateness is determined from heuristics around\n+   * how the worker exitted. Various exit states and velocities may cause the\n+   * watcher to resign.\n+   *\n+   * @param name The name of the worker process.\n+   */\n+  void initWorkerWatcher(const std::string& name);\n+\n+  /// Assume initialization finished, start work.\n+  void start();\n+  /// Turns of various aspects of osquery such as event loops.\n+  void shutdown();\n+  /// Check if a process is an osquery worker.\n+  bool isWorker();\n+\n+ private:\n+  int argc_;\n+  char** argv_;","path":"include/osquery/core.h","position":85,"original_position":85,"commit_id":"6e6ea16b02dbd2acbbb5a79090de8fb456aa2905","original_commit_id":"6e6ea16b02dbd2acbbb5a79090de8fb456aa2905","user":{"login":"theopolis","id":981645,"avatar_url":"https://avatars.githubusercontent.com/u/981645?v=3","gravatar_id":"","url":"https://api.github.com/users/theopolis","html_url":"https://github.com/theopolis","followers_url":"https://api.github.com/users/theopolis/followers","following_url":"https://api.github.com/users/theopolis/following{/other_user}","gists_url":"https://api.github.com/users/theopolis/gists{/gist_id}","starred_url":"https://api.github.com/users/theopolis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theopolis/subscriptions","organizations_url":"https://api.github.com/users/theopolis/orgs","repos_url":"https://api.github.com/users/theopolis/repos","events_url":"https://api.github.com/users/theopolis/events{/privacy}","received_events_url":"https://api.github.com/users/theopolis/received_events","type":"User","site_admin":false},"body":"could be const","created_at":"2015-03-04T22:50:50Z","updated_at":"2015-03-04T22:50:50Z","html_url":"https://github.com/facebook/osquery/pull/818#discussion_r25823019","pull_request_url":"https://api.github.com/repos/facebook/osquery/pulls/818","_links":{"self":{"href":"https://api.github.com/repos/facebook/osquery/pulls/comments/25823019"},"html":{"href":"https://github.com/facebook/osquery/pull/818#discussion_r25823019"},"pull_request":{"href":"https://api.github.com/repos/facebook/osquery/pulls/818"}}},"pull_request":{"url":"https://api.github.com/repos/facebook/osquery/pulls/818","id":30421215,"html_url":"https://github.com/facebook/osquery/pull/818","diff_url":"https://github.com/facebook/osquery/pull/818.diff","patch_url":"https://github.com/facebook/osquery/pull/818.patch","issue_url":"https://api.github.com/repos/facebook/osquery/issues/818","number":818,"state":"open","locked":false,"title":"Extensions autoloading prequel","user":{"login":"theopolis","id":981645,"avatar_url":"https://avatars.githubusercontent.com/u/981645?v=3","gravatar_id":"","url":"https://api.github.com/users/theopolis","html_url":"https://github.com/theopolis","followers_url":"https://api.github.com/users/theopolis/followers","following_url":"https://api.github.com/users/theopolis/following{/other_user}","gists_url":"https://api.github.com/users/theopolis/gists{/gist_id}","starred_url":"https://api.github.com/users/theopolis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theopolis/subscriptions","organizations_url":"https://api.github.com/users/theopolis/orgs","repos_url":"https://api.github.com/users/theopolis/repos","events_url":"https://api.github.com/users/theopolis/events{/privacy}","received_events_url":"https://api.github.com/users/theopolis/received_events","type":"User","site_admin":false},"body":"Working towards: #814\r\n\r\nThis implements the phased initialization.\r\n","created_at":"2015-03-03T22:50:42Z","updated_at":"2015-03-04T22:50:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ecfae2bd816f430811d4e28ab93d68f3e83feed3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/facebook/osquery/pulls/818/commits","review_comments_url":"https://api.github.com/repos/facebook/osquery/pulls/818/comments","review_comment_url":"https://api.github.com/repos/facebook/osquery/pulls/comments{/number}","comments_url":"https://api.github.com/repos/facebook/osquery/issues/818/comments","statuses_url":"https://api.github.com/repos/facebook/osquery/statuses/6e6ea16b02dbd2acbbb5a79090de8fb456aa2905","head":{"label":"theopolis:extensions_load","ref":"extensions_load","sha":"6e6ea16b02dbd2acbbb5a79090de8fb456aa2905","user":{"login":"theopolis","id":981645,"avatar_url":"https://avatars.githubusercontent.com/u/981645?v=3","gravatar_id":"","url":"https://api.github.com/users/theopolis","html_url":"https://github.com/theopolis","followers_url":"https://api.github.com/users/theopolis/followers","following_url":"https://api.github.com/users/theopolis/following{/other_user}","gists_url":"https://api.github.com/users/theopolis/gists{/gist_id}","starred_url":"https://api.github.com/users/theopolis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theopolis/subscriptions","organizations_url":"https://api.github.com/users/theopolis/orgs","repos_url":"https://api.github.com/users/theopolis/repos","events_url":"https://api.github.com/users/theopolis/events{/privacy}","received_events_url":"https://api.github.com/users/theopolis/received_events","type":"User","site_admin":false},"repo":{"id":26103098,"name":"osquery","full_name":"theopolis/osquery","owner":{"login":"theopolis","id":981645,"avatar_url":"https://avatars.githubusercontent.com/u/981645?v=3","gravatar_id":"","url":"https://api.github.com/users/theopolis","html_url":"https://github.com/theopolis","followers_url":"https://api.github.com/users/theopolis/followers","following_url":"https://api.github.com/users/theopolis/following{/other_user}","gists_url":"https://api.github.com/users/theopolis/gists{/gist_id}","starred_url":"https://api.github.com/users/theopolis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theopolis/subscriptions","organizations_url":"https://api.github.com/users/theopolis/orgs","repos_url":"https://api.github.com/users/theopolis/repos","events_url":"https://api.github.com/users/theopolis/events{/privacy}","received_events_url":"https://api.github.com/users/theopolis/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/theopolis/osquery","description":"SQL powered operating system instrumentation and monitoring.","fork":true,"url":"https://api.github.com/repos/theopolis/osquery","forks_url":"https://api.github.com/repos/theopolis/osquery/forks","keys_url":"https://api.github.com/repos/theopolis/osquery/keys{/key_id}","collaborators_url":"https://api.github.com/repos/theopolis/osquery/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/theopolis/osquery/teams","hooks_url":"https://api.github.com/repos/theopolis/osquery/hooks","issue_events_url":"https://api.github.com/repos/theopolis/osquery/issues/events{/number}","events_url":"https://api.github.com/repos/theopolis/osquery/events","assignees_url":"https://api.github.com/repos/theopolis/osquery/assignees{/user}","branches_url":"https://api.github.com/repos/theopolis/osquery/branches{/branch}","tags_url":"https://api.github.com/repos/theopolis/osquery/tags","blobs_url":"https://api.github.com/repos/theopolis/osquery/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/theopolis/osquery/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/theopolis/osquery/git/refs{/sha}","trees_url":"https://api.github.com/repos/theopolis/osquery/git/trees{/sha}","statuses_url":"https://api.github.com/repos/theopolis/osquery/statuses/{sha}","languages_url":"https://api.github.com/repos/theopolis/osquery/languages","stargazers_url":"https://api.github.com/repos/theopolis/osquery/stargazers","contributors_url":"https://api.github.com/repos/theopolis/osquery/contributors","subscribers_url":"https://api.github.com/repos/theopolis/osquery/subscribers","subscription_url":"https://api.github.com/repos/theopolis/osquery/subscription","commits_url":"https://api.github.com/repos/theopolis/osquery/commits{/sha}","git_commits_url":"https://api.github.com/repos/theopolis/osquery/git/commits{/sha}","comments_url":"https://api.github.com/repos/theopolis/osquery/comments{/number}","issue_comment_url":"https://api.github.com/repos/theopolis/osquery/issues/comments{/number}","contents_url":"https://api.github.com/repos/theopolis/osquery/contents/{+path}","compare_url":"https://api.github.com/repos/theopolis/osquery/compare/{base}...{head}","merges_url":"https://api.github.com/repos/theopolis/osquery/merges","archive_url":"https://api.github.com/repos/theopolis/osquery/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/theopolis/osquery/downloads","issues_url":"https://api.github.com/repos/theopolis/osquery/issues{/number}","pulls_url":"https://api.github.com/repos/theopolis/osquery/pulls{/number}","milestones_url":"https://api.github.com/repos/theopolis/osquery/milestones{/number}","notifications_url":"https://api.github.com/repos/theopolis/osquery/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/theopolis/osquery/labels{/name}","releases_url":"https://api.github.com/repos/theopolis/osquery/releases{/id}","created_at":"2014-11-03T03:56:14Z","updated_at":"2015-02-23T01:06:53Z","pushed_at":"2015-03-04T22:46:54Z","git_url":"git://github.com/theopolis/osquery.git","ssh_url":"git@github.com:theopolis/osquery.git","clone_url":"https://github.com/theopolis/osquery.git","svn_url":"https://github.com/theopolis/osquery","homepage":"http://osquery.io","size":5365,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"facebook:master","ref":"master","sha":"c60021f64e576fa6f526d6f52d051879cb875565","user":{"login":"facebook","id":69631,"avatar_url":"https://avatars.githubusercontent.com/u/69631?v=3","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"repo":{"id":22394357,"name":"osquery","full_name":"facebook/osquery","owner":{"login":"facebook","id":69631,"avatar_url":"https://avatars.githubusercontent.com/u/69631?v=3","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/facebook/osquery","description":"SQL powered operating system instrumentation, monitoring, and analytics.","fork":false,"url":"https://api.github.com/repos/facebook/osquery","forks_url":"https://api.github.com/repos/facebook/osquery/forks","keys_url":"https://api.github.com/repos/facebook/osquery/keys{/key_id}","collaborators_url":"https://api.github.com/repos/facebook/osquery/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/facebook/osquery/teams","hooks_url":"https://api.github.com/repos/facebook/osquery/hooks","issue_events_url":"https://api.github.com/repos/facebook/osquery/issues/events{/number}","events_url":"https://api.github.com/repos/facebook/osquery/events","assignees_url":"https://api.github.com/repos/facebook/osquery/assignees{/user}","branches_url":"https://api.github.com/repos/facebook/osquery/branches{/branch}","tags_url":"https://api.github.com/repos/facebook/osquery/tags","blobs_url":"https://api.github.com/repos/facebook/osquery/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/facebook/osquery/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/facebook/osquery/git/refs{/sha}","trees_url":"https://api.github.com/repos/facebook/osquery/git/trees{/sha}","statuses_url":"https://api.github.com/repos/facebook/osquery/statuses/{sha}","languages_url":"https://api.github.com/repos/facebook/osquery/languages","stargazers_url":"https://api.github.com/repos/facebook/osquery/stargazers","contributors_url":"https://api.github.com/repos/facebook/osquery/contributors","subscribers_url":"https://api.github.com/repos/facebook/osquery/subscribers","subscription_url":"https://api.github.com/repos/facebook/osquery/subscription","commits_url":"https://api.github.com/repos/facebook/osquery/commits{/sha}","git_commits_url":"https://api.github.com/repos/facebook/osquery/git/commits{/sha}","comments_url":"https://api.github.com/repos/facebook/osquery/comments{/number}","issue_comment_url":"https://api.github.com/repos/facebook/osquery/issues/comments{/number}","contents_url":"https://api.github.com/repos/facebook/osquery/contents/{+path}","compare_url":"https://api.github.com/repos/facebook/osquery/compare/{base}...{head}","merges_url":"https://api.github.com/repos/facebook/osquery/merges","archive_url":"https://api.github.com/repos/facebook/osquery/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/facebook/osquery/downloads","issues_url":"https://api.github.com/repos/facebook/osquery/issues{/number}","pulls_url":"https://api.github.com/repos/facebook/osquery/pulls{/number}","milestones_url":"https://api.github.com/repos/facebook/osquery/milestones{/number}","notifications_url":"https://api.github.com/repos/facebook/osquery/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/facebook/osquery/labels{/name}","releases_url":"https://api.github.com/repos/facebook/osquery/releases{/id}","created_at":"2014-07-29T20:27:33Z","updated_at":"2015-03-04T22:25:20Z","pushed_at":"2015-03-04T19:46:09Z","git_url":"git://github.com/facebook/osquery.git","ssh_url":"git@github.com:facebook/osquery.git","clone_url":"https://github.com/facebook/osquery.git","svn_url":"https://github.com/facebook/osquery","homepage":"http://osquery.io","size":12589,"stargazers_count":3712,"watchers_count":3712,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":261,"mirror_url":null,"open_issues_count":25,"forks":261,"open_issues":25,"watchers":3712,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/facebook/osquery/pulls/818"},"html":{"href":"https://github.com/facebook/osquery/pull/818"},"issue":{"href":"https://api.github.com/repos/facebook/osquery/issues/818"},"comments":{"href":"https://api.github.com/repos/facebook/osquery/issues/818/comments"},"review_comments":{"href":"https://api.github.com/repos/facebook/osquery/pulls/818/comments"},"review_comment":{"href":"https://api.github.com/repos/facebook/osquery/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/facebook/osquery/pulls/818/commits"},"statuses":{"href":"https://api.github.com/repos/facebook/osquery/statuses/6e6ea16b02dbd2acbbb5a79090de8fb456aa2905"}}}}