Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: port env #9559

Merged
merged 1 commit into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions docs/docs/install/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,10 @@ It only need to be set if the Immich deployment method is changing.

## Ports

| Variable | Description | Default | Services |
| :---------------------- | :-------------------- | :-------: | :-------------------- |
| `HOST` | Host | `0.0.0.0` | server, microservices |
| `SERVER_PORT` | Server Port | `3001` | server |
| `MICROSERVICES_PORT` | Microservices Port | `3002` | microservices |
| `MACHINE_LEARNING_HOST` | Machine Learning Host | `0.0.0.0` | machine learning |
| `MACHINE_LEARNING_PORT` | Machine Learning Port | `3003` | machine learning |
| Variable | Description | Default |
| :------------ | :------------- | :------------------------------------: |
| `IMMICH_HOST` | Listening host | `0.0.0.0` |
| `IMMICH_PORT` | Listening port | 3001 (server), 3003 (machine learning) |

## Database

Expand Down
2 changes: 1 addition & 1 deletion e2e/src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const setup = async () => {
child.stdout.on('data', (data) => {
const input = data.toString();
console.log(input);
if (input.includes('Immich Microservices is listening')) {
if (input.includes('Immich Microservices is running')) {
_resolve();
}
});
Expand Down
8 changes: 4 additions & 4 deletions machine-learning/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

lib_path="/usr/lib/$(arch)-linux-gnu/libmimalloc.so.2"
# mimalloc seems to increase memory usage dramatically with openvino, need to investigate
if ! [ "$DEVICE" = "openvino" ]; then
if ! [ "$DEVICE" = "openvino" ]; then
export LD_PRELOAD="$lib_path"
export LD_BIND_NOW=1
fi

: "${MACHINE_LEARNING_HOST:=[::]}"
: "${MACHINE_LEARNING_PORT:=3003}"
: "${IMMICH_HOST:=[::]}"
: "${IMMICH_PORT:=3003}"
: "${MACHINE_LEARNING_WORKERS:=1}"
: "${MACHINE_LEARNING_WORKER_TIMEOUT:=120}"

gunicorn app.main:app \
-k app.config.CustomUvicornWorker \
-b "$IMMICH_HOST":"$IMMICH_PORT" \
-w "$MACHINE_LEARNING_WORKERS" \
-b "$MACHINE_LEARNING_HOST":"$MACHINE_LEARNING_PORT" \
-t "$MACHINE_LEARNING_WORKER_TIMEOUT" \
--log-config-json log_conf.json \
--graceful-timeout 0
3 changes: 1 addition & 2 deletions server/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,7 @@ export const immichAppConfig: ConfigModuleOptions = {
DB_VECTOR_EXTENSION: Joi.string().optional().valid('pgvector', 'pgvecto.rs').default('pgvecto.rs'),
DB_SKIP_MIGRATIONS: Joi.boolean().optional().default(false),

MACHINE_LEARNING_PORT: Joi.number().optional(),
MICROSERVICES_PORT: Joi.number().optional(),
IMMICH_PORT: Joi.number().optional(),
IMMICH_METRICS_PORT: Joi.number().optional(),

IMMICH_METRICS: Joi.boolean().optional().default(false),
Expand Down
2 changes: 1 addition & 1 deletion server/src/workers/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const host = process.env.HOST;
async function bootstrap() {
otelSDK.start();

const port = Number(process.env.SERVER_PORT) || 3001;
const port = Number(process.env.IMMICH_PORT) || 3001;
const app = await NestFactory.create<NestExpressApplication>(ApiModule, { bufferLogs: true });
const logger = await app.resolve(ILoggerRepository);

Expand Down
7 changes: 2 additions & 5 deletions server/src/workers/microservices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,19 @@ import { ILoggerRepository } from 'src/interfaces/logger.interface';
import { WebSocketAdapter } from 'src/middleware/websocket.adapter';
import { otelSDK } from 'src/utils/instrumentation';

const host = process.env.HOST;

export async function bootstrap() {
otelSDK.start();

const port = Number(process.env.MICROSERVICES_PORT) || 3002;
const app = await NestFactory.create(MicroservicesModule, { bufferLogs: true });
const logger = await app.resolve(ILoggerRepository);
logger.setAppName('ImmichMicroservices');
logger.setContext('ImmichMicroservices');
app.useLogger(logger);
app.useWebSocketAdapter(new WebSocketAdapter(app));

await (host ? app.listen(port, host) : app.listen(port));
await app.listen(0);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't actually use this port, so just pick a random one. (TODO: remove listening entirely in the future)


logger.log(`Immich Microservices is listening on ${await app.getUrl()} [v${serverVersion}] [${envName}] `);
logger.log(`Immich Microservices is running [v${serverVersion}] [${envName}] `);
}

if (!isMainThread) {
Expand Down
Loading