Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
biboumi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
88
Issues
88
List
Boards
Labels
Service Desk
Milestones
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
louiz’
biboumi
Commits
eac144ac
Commit
eac144ac
authored
Apr 21, 2017
by
louiz’
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Configuration options can be overridden by setting env values
parent
cf87cf08
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
14 deletions
+43
-14
CHANGELOG.rst
CHANGELOG.rst
+1
-0
doc/biboumi.1.rst
doc/biboumi.1.rst
+7
-3
src/config/config.cpp
src/config/config.cpp
+35
-11
No files found.
CHANGELOG.rst
View file @
eac144ac
...
...
@@ -14,6 +14,7 @@ Version 5.0
- If the client doesn’t specify any limit, MAM results contain at most 100
messages, instead of the whole archive.
- Multiline topics are now properly handled
- Configuration options can be overridden by values found in the process env.
Version 4.1 - 2017-03-21
========================
...
...
doc/biboumi.1.rst
View file @
eac144ac
...
...
@@ -35,15 +35,19 @@ details on its content.
Configuration
=============
The configuration file uses a simple format of the form
``option=value``.
The configuration file uses a simple format of the form ``option=value``.
The values from the configuration file can be overridden by environment
variables, with the name all in upper case and prefixed with "BIBOUMI_".
For example, if the environment contains “BIBOUMI_PASSWORD=blah", this will
override the value of the “password” option in the configuration file.
Sending SIGUSR1 or SIGUSR2 (see kill(1)) to the process will force it to
re-read the configuration and make it close and re-open the log files. You
can use this to change any configuration option at runtime, or do a log
rotation.
Here is a description of e
ach
possible option:
Here is a description of e
very
possible option:
hostname
--------
...
...
src/config/config.cpp
View file @
eac144ac
#include <config/config.hpp>
#include <utils/tolower.hpp>
#include <iostream>
#include <cstring>
#include <cstdlib>
using
namespace
std
::
string_literals
;
extern
char
**
environ
;
std
::
string
Config
::
filename
{};
std
::
map
<
std
::
string
,
std
::
string
>
Config
::
values
{};
std
::
vector
<
t_config_changed_callback
>
Config
::
callbacks
{};
...
...
@@ -71,21 +76,40 @@ bool Config::read_conf(const std::string& name)
Config
::
clear
();
auto
parse_line
=
[](
const
std
::
string
&
line
,
const
bool
env
)
{
static
const
auto
env_option_prefix
=
"BIBOUMI_"
s
;
if
(
line
==
""
||
line
[
0
]
==
'#'
)
return
;
size_t
pos
=
line
.
find
(
'='
);
if
(
pos
==
std
::
string
::
npos
)
return
;
std
::
string
option
=
line
.
substr
(
0
,
pos
);
std
::
string
value
=
line
.
substr
(
pos
+
1
);
if
(
env
)
{
auto
a
=
option
.
substr
(
0
,
env_option_prefix
.
size
());
if
(
a
==
env_option_prefix
)
option
=
utils
::
tolower
(
option
.
substr
(
env_option_prefix
.
size
()));
else
return
;
}
Config
::
values
[
option
]
=
value
;
};
std
::
string
line
;
size_t
pos
;
std
::
string
option
;
std
::
string
value
;
while
(
file
.
good
())
{
std
::
getline
(
file
,
line
);
if
(
line
==
""
||
line
[
0
]
==
'#'
)
continue
;
pos
=
line
.
find
(
'='
);
if
(
pos
==
std
::
string
::
npos
)
continue
;
option
=
line
.
substr
(
0
,
pos
);
value
=
line
.
substr
(
pos
+
1
);
Config
::
values
[
option
]
=
value
;
parse_line
(
line
,
false
);
}
char
**
env_line
=
environ
;
while
(
*
env_line
)
{
parse_line
(
*
env_line
,
true
);
env_line
++
;
}
return
true
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment