Permalink
Browse files

allow conf file pathname config with app env var (capflam)

Prior to this change you could customize the path to the configuration
file with the --conf command line argument, otherwise Yaws would use
the default configuration file. With this patch, you can also use the
application environment variable "config" to set the path of the
default configuration file.
  • Loading branch information...
capflam authored and vinoski committed May 3, 2011
1 parent 9bb7178 commit fd3ca71690e7e137b4212ede2273cbf966ba0875
Showing with 19 additions and 11 deletions.
  1. +6 −4 man/yaws.1
  2. +1 −0 src/yaws.app.src
  3. +12 −7 src/yaws_config.erl
View
@@ -53,10 +53,12 @@ debug mode.
.TP
\fB\--conf file\fR
-Use a different configuration file than the default. The default configuration file
-when running as root is /etc/yaws/yaws.conf. When running as a non priviliged user, yaws
-will search for its configuration file in the following order. First in
-$HOME/yaws.conf, then in ./yaws.conf and finally in /etc/yaws/yaws.conf
+Use a different configuration file than the default. If the configuration
+parameter \fIconfig\fR is set, yaws use it as default configuration file. Else,
+The default configuration file when running as root is /etc/yaws/yaws.conf. When
+running as a non priviliged user, yaws will search for its configuration file in
+the following order. First in $HOME/yaws.conf, then in ./yaws.conf and finally
+in /etc/yaws/yaws.conf.
.TP
\fB\--runmod module\fR
Tells yaws to call \fImodule:start/0\fR at startup. This makes it possible
View
@@ -5,6 +5,7 @@
{registered, []},
{mod,{yaws_app,[]}},
{env, [
+ % {config, undefined}, % undefined | filename()
% {debug, false}, % true | false
% {trace, false}, % http | traffic | false
% {traceoutput, false}, % true | false
View
@@ -29,13 +29,18 @@
%% where to look for yaws.conf
paths() ->
- case yaws:getuid() of
- {ok, "0"} -> %% root
- [yaws_generated:etcdir() ++ "/yaws/yaws.conf"];
- _ -> %% developer
- [filename:join([yaws:home(), "yaws.conf"]),
- "./yaws.conf",
- yaws_generated:etcdir() ++ "/yaws/yaws.conf"]
+ case application:get_env(yaws, config) of
+ undefined ->
+ case yaws:getuid() of
+ {ok, "0"} -> %% root
+ [yaws_generated:etcdir() ++ "/yaws/yaws.conf"];
+ _ -> %% developer
+ [filename:join([yaws:home(), "yaws.conf"]),
+ "./yaws.conf",
+ yaws_generated:etcdir() ++ "/yaws/yaws.conf"]
+ end;
+ {ok, File} ->
+ [File]
end.

0 comments on commit fd3ca71

Please sign in to comment.