summaryrefslogtreecommitdiff
path: root/src/couch/src/couch_sup.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/couch/src/couch_sup.erl')
-rw-r--r--src/couch/src/couch_sup.erl36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/couch/src/couch_sup.erl b/src/couch/src/couch_sup.erl
index 8dcaf1dc7..9075a9ebc 100644
--- a/src/couch/src/couch_sup.erl
+++ b/src/couch/src/couch_sup.erl
@@ -28,6 +28,8 @@
start_link() ->
+ assert_admins(),
+ launch_admin_annoyance_reporter(),
write_pidfile(),
notify_starting(),
@@ -87,6 +89,40 @@ handle_config_change(_, _, _, _, _) ->
handle_config_terminate(_Server, _Reason, _State) ->
ok.
+assert_admins() ->
+ couch_log:info("Preflight check: Asserting Admin Account~n", []),
+ case {config:get("admins"), os:getenv("COUCH_TEST_ADMIN_PARTY_OVERRIDE")} of
+ {[], false} ->
+ couch_log:info("~n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%~n"
+ ++ " No Admin Account Found, aborting startup. ~n"
+ ++ " Please configure an admin account in your local.ini file. ~n"
+ ++ "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%~n", []),
+ % Wait a second so the log message can make it to the log
+ timer:sleep(500),
+ throw(admin_account_required);
+ _ -> ok
+ end.
+
+
+maybe_send_no_admin_account_error_message() ->
+ case os:getenv("COUCH_TEST_ADMIN_PARTY_OVERRIDE") of
+ false ->
+ ok;
+ _ ->
+ couch_log:error("No Admin Account configured."
+ ++ " Please configure an Admin Account in your local.ini file and restart CouchDB.~n", [])
+ end,
+ launch_admin_annoyance_reporter().
+
+admin_annoyance_interval() ->
+ FiveMinutes = 5 * 1000 * 60,
+ timer:sleep(FiveMinutes),
+ maybe_send_no_admin_account_error_message().
+
+launch_admin_annoyance_reporter() ->
+ spawn_link(fun admin_annoyance_interval/0).
+
+
notify_starting() ->
couch_log:info("Apache CouchDB ~s is starting.~n", [
couch_server:get_version()