forked from amatas/couchdb-centos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
couchdb-0012-Expand-.d-directories-in-erlang.patch
104 lines (94 loc) · 3.07 KB
/
couchdb-0012-Expand-.d-directories-in-erlang.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
From: Robert Newson <[email protected]>
Date: Sun, 6 Jul 2014 23:47:23 +0100
Subject: [PATCH] Expand .d directories in erlang
diff --git a/bin/couchdb.tpl.in b/bin/couchdb.tpl.in
index ba034cc..ffdbb17 100644
--- a/bin/couchdb.tpl.in
+++ b/bin/couchdb.tpl.in
@@ -120,7 +120,7 @@ _get_pid () {
echo $PID
}
-_add_config_file () {
+_add_config_path () {
if test -z "$print_arguments"; then
print_arguments="$1"
else
@@ -134,14 +134,6 @@ EOF
background_start_arguments="$background_start_arguments -a $1"
}
-_add_config_dir () {
- for file in "$1"/*.ini; do
- if [ -r "$file" ]; then
- _add_config_file "$file"
- fi
- done
-}
-
_add_erlang_config () {
if [ -r "$1" ]; then
ERL_START_OPTIONS="$ERL_START_OPTIONS -config '$1'"
@@ -149,15 +141,15 @@ _add_erlang_config () {
}
_load_config () {
- _add_config_file "$DEFAULT_CONFIG_FILE"
- _add_config_dir "$DEFAULT_CONFIG_DIR"
+ _add_config_path "$DEFAULT_CONFIG_FILE"
+ _add_config_path "$DEFAULT_CONFIG_DIR"
# We initialize plugins here to get the desired default config load order
_find_plugins
- _add_config_file "$LOCAL_CONFIG_FILE"
- _add_config_dir "$LOCAL_CONFIG_DIR"
+ _add_config_path "$LOCAL_CONFIG_DIR"
+ _add_config_path "$LOCAL_CONFIG_FILE"
if [ "$COUCHDB_ADDITIONAL_CONFIG_FILE" != '' ]
then
- _add_config_file "$COUCHDB_ADDITIONAL_CONFIG_FILE"
+ _add_config_path "$COUCHDB_ADDITIONAL_CONFIG_FILE"
fi
}
@@ -238,7 +230,7 @@ _find_plugins () {
else
ERL_ZFLAGS="$ERL_ZFLAGS -pz '$plugin/ebin'"
fi
- _add_config_dir "$plugin/priv/default.d"
+ _add_config_path "$plugin/priv/default.d"
_add_erlang_config "$plugin/priv/couch_plugin.config"
fi
done
@@ -358,8 +350,8 @@ parse_script_option_list () {
case "$1" in
-h) shift; display_help; exit;;
-V) shift; display_version; exit;;
- -a) shift; _add_config_file "$1"; shift;;
- -A) shift; _add_config_dir "$1"; shift;;
+ -a) shift; _add_config_path "$1"; shift;;
+ -A) shift; _add_config_path "$1"; shift;;
-n) shift; _reset_config;;
-c) shift; _print_config; exit;;
-i) shift; INTERACTIVE=true;;
diff --git a/src/couchdb/couch_app.erl b/src/couchdb/couch_app.erl
index 42411a8..d6d8c0c 100644
--- a/src/couchdb/couch_app.erl
+++ b/src/couchdb/couch_app.erl
@@ -15,6 +15,7 @@
-behaviour(application).
-include("couch_db.hrl").
+-include_lib("kernel/include/file.hrl").
-export([start/2, stop/1]).
@@ -37,7 +38,16 @@ get_ini_files(Default) ->
{ok, [[]]} ->
Default;
{ok, [Values]} ->
- Values
+ lists:flatmap(fun(V) ->
+ case file:read_file_info(V) of
+ {ok, #file_info{type = regular}} ->
+ [V];
+ {ok, #file_info{type = directory}} ->
+ lists:sort(filelib:wildcard(filename:join([V, "*.ini"])));
+ {error, enoent} ->
+ []
+ end
+ end, Values)
end.
start_apps([]) ->