mirror of
https://github.com/Ryujinx/Ryujinx-Ldn-Website.git
synced 2025-08-11 11:11:06 +00:00
Add DATA_PATH env var
This commit is contained in:
parent
5a270a0eab
commit
be3e724868
17
README.md
17
README.md
|
@ -20,14 +20,15 @@
|
|||
|
||||
This app can be configured using the following environment variables:
|
||||
|
||||
| Name | Description | Default value | Notes |
|
||||
| :------------- | ----------------------------------------------------------------------------------------- | :-----------: | ---------------------------------------------------------------------- |
|
||||
| `NODE_ENV` | This should be set to `production` or `development` depending on the current environment. | `""` | |
|
||||
| `SOCKET_PATH` | The path to the unix socket this server should be listening on. | `""` | If this is not empty `HOST` and `PORT` will be ignored. |
|
||||
| `HOST` | The address this server should be listening on. | `"127.0.0.1"` | |
|
||||
| `PORT` | The port this server should be using. | `3000` | |
|
||||
| `REDIS_URL` | The URL of the redis server. | `""` | Format: `redis[s]://[[username][:password]@][host][:port][/db-number]` |
|
||||
| `REDIS_SOCKET` | The path to the unix socket of the redis server. | `""` | If this is not empty `REDIS_URL` will be ignored. |
|
||||
| Name | Description | Default value | Notes |
|
||||
| :------------- | ----------------------------------------------------------------------------------------- | :-----------: | ------------------------------------------------------------------------------------------------------------ |
|
||||
| `NODE_ENV` | This should be set to `production` or `development` depending on the current environment. | `""` | |
|
||||
| `DATA_PATH` | The path to the data directory of this server. | `"data"` | This can either be a relative path or an absolute path. Currently this directory only contains the log file. |
|
||||
| `SOCKET_PATH` | The path to the unix socket this server should be listening on. | `""` | If this is not empty `HOST` and `PORT` will be ignored. |
|
||||
| `HOST` | The address this server should be listening on. | `"127.0.0.1"` | |
|
||||
| `PORT` | The port this server should be using. | `3000` | |
|
||||
| `REDIS_URL` | The URL of the redis server. | `""` | Format: `redis[s]://[[username][:password]@][host][:port][/db-number]` |
|
||||
| `REDIS_SOCKET` | The path to the unix socket of the redis server. | `""` | If this is not empty `REDIS_URL` will be ignored. |
|
||||
|
||||
## Contribute
|
||||
|
||||
|
|
|
@ -10,6 +10,11 @@ import {
|
|||
import winston from "winston";
|
||||
import apiRouter from "./api";
|
||||
import { errorLogger, requestLogger } from "./middleware";
|
||||
import { mkdirSync } from "fs";
|
||||
|
||||
// Prepare data directory
|
||||
const dataDirectory = process.env.DATA_PATH ?? "data";
|
||||
mkdirSync(dataDirectory, { recursive: true });
|
||||
|
||||
// Init logger
|
||||
const loggerInstance = winston.createLogger({
|
||||
|
@ -17,7 +22,7 @@ const loggerInstance = winston.createLogger({
|
|||
transports: [
|
||||
new winston.transports.Console(),
|
||||
new winston.transports.File({
|
||||
filename: `data/ryujinx-ldn-website.log`,
|
||||
filename: `${dataDirectory}/ryujinx-ldn-website.log`,
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
|
|
@ -5,7 +5,11 @@ import http from "http";
|
|||
const server = http.createServer(app);
|
||||
|
||||
if (process.env.SOCKET_PATH != null && process.env.SOCKET_PATH.length > 0) {
|
||||
server.listen(process.env.SOCKET_PATH);
|
||||
server.listen({
|
||||
path: process.env.SOCKET_PATH,
|
||||
readableAll: true,
|
||||
writableAll: true,
|
||||
});
|
||||
}
|
||||
else {
|
||||
server.listen(parseInt(env.PORT || "3000"), env.HOST || "127.0.0.1");
|
||||
|
|
Loading…
Reference in a new issue