Skip to content

Commit 6185ca6

Browse files
committed
Make the log directory configurable
1 parent cf7a87b commit 6185ca6

File tree

5 files changed

+22
-11
lines changed

5 files changed

+22
-11
lines changed

doc/Installation.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@ You can run the server by:
5151
bin/lorawan-server
5252
```
5353

54-
By default the database directory `Mnesia.lorawan@*` and the `log` files are
55-
stored in the `lorawan-server` directory you created. If you want to store the
56-
run-time information to another directory, set the `LORAWAN_HOME` environment
57-
variable.
54+
By default the database directory `Mnesia.lorawan@*` is stored in
55+
the `lorawan-server` directory you created. If you want to store the run-time
56+
information to another directory, set the `LORAWAN_HOME` environment variable.
57+
58+
The `log` files are by default stored in the same directory. If you want to
59+
store the log files elsewhere, set the `LORAWAN_LOG_ROOT` variable.
5860

5961
The lorawan-server can be started in background as a daemon.
6062
On Linux systems with systemd you should:
@@ -63,7 +65,8 @@ On Linux systems with systemd you should:
6365
* Create a dedicated user by `useradd --home-dir /var/lib/lorawan-server --create-home lorawan`
6466
* Start the server by `systemctl start lorawan-server`
6567

66-
This will put the database and the logs into `/var/lib/lorawan-server`.
68+
This will put the database into `/var/lib/lorawan-server` and server logs into
69+
`/var/log/lorawan-server`.
6770

6871
### Using the Binary Release on Windows
6972

lorawan_server.config

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@
3737
% {error_logger_hwm, undefined},
3838
{handlers, [
3939
% {lager_console_backend, [{level, debug}]},
40-
{lager_file_backend, [{file, "log/debug.log"}, {level, debug}]},
41-
{lager_file_backend, [{file, "log/error.log"}, {level, error}]}
42-
]}
40+
{lager_file_backend, [{file, "debug.log"}, {level, debug}]},
41+
{lager_file_backend, [{file, "error.log"}, {level, error}]}
42+
]},
43+
{crash_log, "crash.log"}
4344
]},
4445
{sasl, [
4546
{errlog_type, error}

scripts/lorawan-server

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@ elif [ -L "$__possible_sys".orig ]; then
1717
SYS_CONFIG="$__possible_sys"
1818
fi
1919

20+
if [ ! -z $LORAWAN_LOG_ROOT ]; then
21+
ERL_ARGS="-lager log_root \"$LORAWAN_LOG_ROOT\""
22+
else
23+
ERL_ARGS="-lager log_root \"log\""
24+
fi
2025
if [ ! -z $GOOGLE_MAPS_KEY ]; then
2126
sed -i "s/GoogleMapsKey = \"[-a-zA-Z0-9]*\"/GoogleMapsKey = \"$GOOGLE_MAPS_KEY\"/g" $ROOT_DIR/lib/lorawan_server-*/priv/admin/admin-config.js
2227
fi
2328

24-
cd $LORAWAN_HOME && erl -noinput +Bd -sname lorawan -pa $ROOT_DIR/lib/*/ebin -s lorawan_app -config $SYS_CONFIG $@
29+
cd $LORAWAN_HOME && erl -noinput +Bd -sname lorawan -pa $ROOT_DIR/lib/*/ebin -s lorawan_app $ERL_ARGS -config $SYS_CONFIG $@

scripts/lorawan-server.bat

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ setlocal EnableDelayedExpansion
44
for /D %%A in ("%PROGRAMFILES%\erl*" "%PROGRAMFILES(x86)%\erl*") do (
55
for /D %%B in ("%%A\erts*") do (
66
for /D %%C in ("%%B\bin\erl.exe") do (
7-
set "ERLDIR=%%C"
7+
set "ERL_DIR=%%C"
88
)
99
)
1010
)
@@ -18,4 +18,5 @@ for /D %%A in ("%ROOT_DIR%\lib\*") do (
1818
set FILES=!FILES! "%%A\ebin"
1919
)
2020

21-
cd %ROOT_DIR% && %ERLDIR% -noinput +Bd -sname lorawan -pa !FILES! -s lorawan_app -config releases/{{release_version}}/sys.config
21+
set "ERL_ARGS=-lager log_root "log""
22+
cd %ROOT_DIR% && %ERL_DIR% -noinput +Bd -sname lorawan -pa !FILES! -s lorawan_app %ERL_ARGS% -config releases/{{release_version}}/sys.config

scripts/lorawan-server.service

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ After=network.target
55
[Service]
66
Type=simple
77
Environment=LORAWAN_HOME=/var/lib/lorawan-server
8+
Environment=LORAWAN_LOG_ROOT=/var/log/lorawan-server
89
ExecStart=/usr/lib/lorawan-server/bin/lorawan-server
910
ExecStop=/usr/lib/lorawan-server/bin/lorawanctl stop
1011
User=lorawan

0 commit comments

Comments
 (0)