You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2017/05/16 17:32:29 UTC

[couchdb] branch start-app-order updated (9eb9f31 -> 9ddfe07)

This is an automated email from the ASF dual-hosted git repository.

davisp pushed a change to branch start-app-order
in repository https://gitbox.apache.org/repos/asf/couchdb.git.

  discards  9eb9f31   Pre-calculate application start order
       new  9ddfe07   Pre-calculate application start order

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (9eb9f31)
            \
             N -- N -- N   refs/heads/start-app-order (9ddfe07)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omits" are not gone; other references still
refer to them.  Any revisions marked "discards" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "adds" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/couch/src/test_util.erl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
To stop receiving notification emails like this one, please contact
['"commits@couchdb.apache.org" <co...@couchdb.apache.org>'].

[couchdb] 01/01: Pre-calculate application start order

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch start-app-order
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 9ddfe07a2d69dcddba1002d069f966845e3f6e0d
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Tue May 16 11:12:24 2017 -0500

    Pre-calculate application start order
    
    This allows us to make some better assertions/logging when starting our
    application list on what should and should not already be started.
---
 src/couch/src/test_util.erl | 42 ++++++++++++++++++++++++++++++++++++------
 1 file changed, 36 insertions(+), 6 deletions(-)

diff --git a/src/couch/src/test_util.erl b/src/couch/src/test_util.erl
index 3c4d170..efaf49c 100644
--- a/src/couch/src/test_util.erl
+++ b/src/couch/src/test_util.erl
@@ -83,18 +83,18 @@ stop_couch(_) ->
     stop_couch().
 
 start_applications(Apps) ->
-    start_applications(Apps, []).
+    StartOrder = calculate_start_order(Apps),
+    start_applications(StartOrder, []).
 
 start_applications([], Acc) ->
     lists:reverse(Acc);
+start_applications([App|Apps], Acc) when App == kernel; App == stdlib ->
+    start_applications(Apps, Acc);
 start_applications([App|Apps], Acc) ->
     case application:start(App) of
     {error, {already_started, _}} ->
-        start_applications(Apps, Acc);
-    {error, {not_started, Dep}} ->
-        start_applications([Dep, App | Apps], Acc);
-    {error, {not_running, Dep}} ->
-        start_applications([Dep, App | Apps], Acc);
+        io:format(standard_error, "Application ~s was left running!~n", [App]),
+        start_applications(Apps, [App|Acc]);
     ok ->
         start_applications(Apps, [App|Acc])
     end.
@@ -258,3 +258,33 @@ load_applications_with_stats() ->
 stats_file_to_app(File) ->
     [_Desc, _Priv, App|_] = lists:reverse(filename:split(File)),
     erlang:list_to_atom(App).
+
+calculate_start_order(Apps) ->
+    calculate_start_order(Apps, []).
+
+calculate_start_order([], StartOrder) ->
+    lists:reverse(StartOrder);
+calculate_start_order([App | RestApps], StartOrder) ->
+    NewStartOrder = load_app_deps(App, StartOrder),
+    calculate_start_order(RestApps, NewStartOrder).
+
+load_app_deps(App, StartOrder) ->
+    case lists:member(App, StartOrder) of
+        true ->
+            StartOrder;
+        false ->
+            case application:load(App) of
+                ok -> ok;
+                {error, {already_loaded, App}} -> ok
+            end,
+            {ok, Apps} = application:get_key(App, applications),
+            Deps = case App of
+                kernel -> Apps;
+                stdlib -> Apps;
+                _ -> lists:usort([kernel, stdlib | Apps])
+            end,
+            NewStartOrder = lists:foldl(fun(Dep, Acc) ->
+                load_app_deps(Dep, Acc)
+            end, StartOrder, Deps),
+            [App | NewStartOrder]
+    end.

-- 
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.