diff --git a/README.md b/README.md index 2df24fc..8d8e284 100644 --- a/README.md +++ b/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 diff --git a/src/app.ts b/src/app.ts index affa687..e7adc03 100644 --- a/src/app.ts +++ b/src/app.ts @@ -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`, }), ], }); diff --git a/src/index.ts b/src/index.ts index 8a62abf..67115f9 100755 --- a/src/index.ts +++ b/src/index.ts @@ -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");