Skip to content

Commit

Permalink
allow conf file pathname config with app env var (capflam)
Browse files Browse the repository at this point in the history
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
Christopher Faulet authored and vinoski committed May 24, 2011
1 parent 9bb7178 commit fd3ca71
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
10 changes: 6 additions & 4 deletions man/yaws.1
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/yaws.app.src
Expand Up @@ -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
Expand Down
19 changes: 12 additions & 7 deletions src/yaws_config.erl
Expand Up @@ -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.


Expand Down

0 comments on commit fd3ca71

Please sign in to comment.