diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 03211d5..43866c9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -114,9 +114,40 @@ Flowise has 3 different modules in a single mono repository. 11. Commit code and submit Pull Request from forked branch pointing to [Flowise master](https://github.com/FlowiseAI/Flowise/tree/master). +## 🌱 Env Variables + +Flowise support different environment variables to configure your instance. You can specify the following variables in the `.env` file inside `packages/server` folder. Read [more](https://docs.flowiseai.com/environment-variables) + +| Variable | Description | Type | Default | +| -------------------------- | ---------------------------------------------------------------- | ------------------------------------------------ | ----------------------------------- | +| PORT | The HTTP port Flowise runs on | Number | 3000 | +| FLOWISE_USERNAME | Username to login | String | | +| FLOWISE_PASSWORD | Password to login | String | | +| DEBUG | Print logs from components | Boolean | | +| LOG_PATH | Location where log files are stored | String | `your-path/Flowise/logs` | +| LOG_LEVEL | Different levels of logs | Enum String: `error`, `info`, `verbose`, `debug` | `info` | +| APIKEY_PATH | Location where api keys are saved | String | `your-path/Flowise/packages/server` | +| EXECUTION_MODE | Whether predictions run in their own process or the main process | Enum String: `child`, `main` | `main` | +| TOOL_FUNCTION_BUILTIN_DEP | NodeJS built-in modules to be used for Tool Function | String | | +| TOOL_FUNCTION_EXTERNAL_DEP | External modules to be used for Tool Function | String | | +| OVERRIDE_DATABASE | Override current database with default | Enum String: `true`, `false` | `true` | +| DATABASE_TYPE | Type of database to store the flowise data | Enum String: `sqlite`, `mysql`, `postgres` | `sqlite` | +| DATABASE_PATH | Location where database is saved (When DATABASE_TYPE is sqlite) | String | `your-home-dir/.flowise` | +| DATABASE_HOST | Host URL or IP address (When DATABASE_TYPE is not sqlite) | String | | +| DATABASE_PORT | Database port (When DATABASE_TYPE is not sqlite) | String | | +| DATABASE_USERNAME | Database username (When DATABASE_TYPE is not sqlite) | String | | +| DATABASE_PASSWORD | Database password (When DATABASE_TYPE is not sqlite) | String | | +| DATABASE_NAME | Database name (When DATABASE_TYPE is not sqlite) | String | | + +You can also specify the env variables when using `npx`. For example: + +``` +npx flowise start --PORT=3000 --DEBUG=true +``` + ## 📖 Contribute to Docs -In-Progress +[Flowise Docs](https://github.com/FlowiseAI/FlowiseDocs) ## 🏷️ Pull Request process diff --git a/README.md b/README.md index 281d756..13da942 100644 --- a/README.md +++ b/README.md @@ -135,34 +135,7 @@ FLOWISE_PASSWORD=1234 ## 🌱 Env Variables -Flowise support different environment variables to configure your instance. You can specify the following variables in the `.env` file inside `packages/server` folder. Read [more](https://docs.flowiseai.com/environment-variables) - -| Variable | Description | Type | Default | -| ---------------- | ---------------------------------------------------------------- | ------------------------------------------------ | ----------------------------------- | -| PORT | The HTTP port Flowise runs on | Number | 3000 | -| FLOWISE_USERNAME | Username to login | String | | -| FLOWISE_PASSWORD | Password to login | String | | -| DEBUG | Print logs from components | Boolean | | -| LOG_PATH | Location where log files are stored | String | `your-path/Flowise/logs` | -| LOG_LEVEL | Different levels of logs | Enum String: `error`, `info`, `verbose`, `debug` | `info` | -| APIKEY_PATH | Location where api keys are saved | String | `your-path/Flowise/packages/server` | -| EXECUTION_MODE | Whether predictions run in their own process or the main process | Enum String: `child`, `main` | `main` | -| TOOL_FUNCTION_BUILTIN_DEP | NodeJS built-in modules to be used for Tool Function | String | | -| TOOL_FUNCTION_EXTERNAL_DEP | External modules to be used for Tool Function | String | | -| OVERRIDE_DATABASE | Override current database with default | Enum String: `true`, `false` | `true` | -| DATABASE_TYPE | Type of database to store the flowise data | Enum String: `sqlite`, `mysql`, `postgres` | `sqlite` | -| DATABASE_PATH | Location where database is saved (When DATABASE_TYPE is sqlite) | String | `your-home-dir/.flowise` | -| DATABASE_HOST | Host URL or IP address (When DATABASE_TYPE is not sqlite) | String | | -| DATABASE_PORT | Database port (When DATABASE_TYPE is not sqlite) | String | | -| DATABASE_USERNAME | Database username (When DATABASE_TYPE is not sqlite) | String | | -| DATABASE_PASSWORD | Database password (When DATABASE_TYPE is not sqlite) | String | | -| DATABASE_NAME | Database name (When DATABASE_TYPE is not sqlite) | String | | - -You can also specify the env variables when using `npx`. For example: - -``` -npx flowise start --PORT=3000 --DEBUG=true -``` +Flowise support different environment variables to configure your instance. You can specify the following variables in the `.env` file inside `packages/server` folder. Read [more](https://github.com/FlowiseAI/Flowise/blob/main/CONTRIBUTING.md#-env-variables) ## 📖 Documentation diff --git a/docker/.env.example b/docker/.env.example index 42dc696..e7d3527 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -1,5 +1,14 @@ PORT=3000 +OVERRIDE_DATABASE=true +DATABASE_TYPE=sqlite DATABASE_PATH=/root/.flowise +# When database is not sqlite +# DATABASE_PORT="" +# DATABASE_HOST="" +# DATABASE_NAME="flowise" +# DATABASE_USER="" +# DATABASE_PASSWORD="" + APIKEY_PATH=/root/.flowise LOG_PATH=/root/.flowise/logs # FLOWISE_USERNAME=user @@ -8,4 +17,4 @@ LOG_PATH=/root/.flowise/logs # LOG_LEVEL=debug (error | warn | info | verbose | debug) # EXECUTION_MODE=child or main # TOOL_FUNCTION_BUILTIN_DEP=crypto,fs -# TOOL_FUNCTION_EXTERNAL_DEP=moment,lodash \ No newline at end of file +# TOOL_FUNCTION_EXTERNAL_DEP=moment,lodash diff --git a/docker/README.md b/docker/README.md index d0ce5a7..0060fa3 100644 --- a/docker/README.md +++ b/docker/README.md @@ -9,7 +9,7 @@ Starts Flowise from [DockerHub Image](https://hub.docker.com/repository/docker/f 3. Open [http://localhost:3000](http://localhost:3000) 4. You can bring the containers down by `docker-compose stop` -## 🔒 Authrorization +## 🔒 Authentication 1. Create `.env` file and specify the `PORT`, `FLOWISE_USERNAME`, and `FLOWISE_PASSWORD` (refer to `.env.example`) 2. Pass `FLOWISE_USERNAME` and `FLOWISE_PASSWORD` to the `docker-compose.yml` file: @@ -32,17 +32,3 @@ If you like to persist your data (flows, logs, apikeys), set these variables in - LOG_PATH=/root/.flowise/logs Flowise also support different environment variables to configure your instance. Read [more](https://docs.flowiseai.com/environment-variables) - -| Variable | Description | Type | Default | -| -------------------------- | ---------------------------------------------------------------- | ------------------------------------------------ | ----------------------------------- | -| PORT | The HTTP port Flowise runs on | Number | 3000 | -| FLOWISE_USERNAME | Username to login | String | -| FLOWISE_PASSWORD | Password to login | String | -| DEBUG | Print logs onto terminal/console | Boolean | -| LOG_PATH | Location where log files are stored | String | `your-path/Flowise/packages/server` | -| LOG_LEVEL | Different log levels for loggers to be saved | Enum String: `error`, `info`, `verbose`, `debug` | `info` | -| DATABASE_PATH | Location where database is saved | String | `your-home-dir/.flowise` | -| APIKEY_PATH | Location where api keys are saved | String | `your-path/Flowise/packages/server` | -| EXECUTION_MODE | Whether predictions run in their own process or the main process | Enum String: `child`, `main` | `main` | -| TOOL_FUNCTION_BUILTIN_DEP | NodeJS built-in modules to be used for Tool Function | String | | -| TOOL_FUNCTION_EXTERNAL_DEP | External modules to be used for Tool Function | String | | diff --git a/packages/server/.env.example b/packages/server/.env.example index 923c62a..1b33382 100644 --- a/packages/server/.env.example +++ b/packages/server/.env.example @@ -1,18 +1,7 @@ PORT=3000 -# FLOWISE_USERNAME=user -# FLOWISE_PASSWORD=1234 -# DEBUG=true -# APIKEY_PATH=/your_api_key_path/.flowise -# LOG_PATH=/your_log_path/.flowise/logs -# LOG_LEVEL=debug (error | warn | info | verbose | debug) -# EXECUTION_MODE=main (child | main) - -OVERRIDE_DATABASE="true" -DATABASE_TYPE="sqlite" # sqlite, mysql, postgres - -# When database is sqlite +OVERRIDE_DATABASE=true +DATABASE_TYPE=sqlite # DATABASE_PATH=/your_database_path/.flowise - # When database is not sqlite # DATABASE_PORT="" # DATABASE_HOST="" @@ -20,5 +9,12 @@ DATABASE_TYPE="sqlite" # sqlite, mysql, postgres # DATABASE_USER="" # DATABASE_PASSWORD="" +# FLOWISE_USERNAME=user +# FLOWISE_PASSWORD=1234 +# DEBUG=true +# APIKEY_PATH=/your_api_key_path/.flowise +# LOG_PATH=/your_log_path/.flowise/logs +# LOG_LEVEL=debug (error | warn | info | verbose | debug) +# EXECUTION_MODE=main (child | main) # TOOL_FUNCTION_BUILTIN_DEP=crypto,fs # TOOL_FUNCTION_EXTERNAL_DEP=moment,lodash diff --git a/packages/server/src/ChildProcess.ts b/packages/server/src/ChildProcess.ts index a93906c..f0117b6 100644 --- a/packages/server/src/ChildProcess.ts +++ b/packages/server/src/ChildProcess.ts @@ -144,13 +144,14 @@ export class ChildProcess { async function initDB() { let childAppDataSource let homePath + const synchronize = process.env.OVERRIDE_DATABASE === 'false' ? false : true switch (process.env.DATABASE_TYPE) { case 'sqlite': homePath = process.env.DATABASE_PATH ?? path.join(getUserHome(), '.flowise') childAppDataSource = new DataSource({ type: 'sqlite', database: path.resolve(homePath, 'database.sqlite'), - synchronize: process.env.OVERRIDE_DATABASE == 'true', + synchronize, entities: [ChatFlow, ChatMessage, Tool], migrations: [] }) @@ -164,7 +165,7 @@ async function initDB() { password: process.env.DATABASE_PASSWORD, database: process.env.DATABASE_NAME, charset: 'utf8mb4', - synchronize: process.env.OVERRIDE_DATABASE == 'true', + synchronize, entities: [ChatFlow, ChatMessage, Tool], migrations: [] }) @@ -177,7 +178,7 @@ async function initDB() { username: process.env.DATABASE_USER, password: process.env.DATABASE_PASSWORD, database: process.env.DATABASE_NAME, - synchronize: process.env.OVERRIDE_DATABASE == 'true', + synchronize, entities: [ChatFlow, ChatMessage, Tool], migrations: [] }) @@ -187,7 +188,7 @@ async function initDB() { childAppDataSource = new DataSource({ type: 'sqlite', database: path.resolve(homePath, 'database.sqlite'), - synchronize: process.env.OVERRIDE_DATABASE == 'true', + synchronize, entities: [ChatFlow, ChatMessage, Tool], migrations: [] }) diff --git a/packages/server/src/DataSource.ts b/packages/server/src/DataSource.ts index 958074c..14e2266 100644 --- a/packages/server/src/DataSource.ts +++ b/packages/server/src/DataSource.ts @@ -10,13 +10,14 @@ let appDataSource: DataSource export const init = async (): Promise => { let homePath + const synchronize = process.env.OVERRIDE_DATABASE === 'false' ? false : true switch (process.env.DATABASE_TYPE) { case 'sqlite': homePath = process.env.DATABASE_PATH ?? path.join(getUserHome(), '.flowise') appDataSource = new DataSource({ type: 'sqlite', database: path.resolve(homePath, 'database.sqlite'), - synchronize: process.env.OVERRIDE_DATABASE == 'true', + synchronize, entities: [ChatFlow, ChatMessage, Tool], migrations: [] }) @@ -30,7 +31,7 @@ export const init = async (): Promise => { password: process.env.DATABASE_PASSWORD, database: process.env.DATABASE_NAME, charset: 'utf8mb4', - synchronize: process.env.OVERRIDE_DATABASE == 'true', + synchronize, entities: [ChatFlow, ChatMessage, Tool], migrations: [] }) @@ -43,7 +44,7 @@ export const init = async (): Promise => { username: process.env.DATABASE_USER, password: process.env.DATABASE_PASSWORD, database: process.env.DATABASE_NAME, - synchronize: process.env.OVERRIDE_DATABASE == 'true', + synchronize, entities: [ChatFlow, ChatMessage, Tool], migrations: [] }) @@ -53,7 +54,7 @@ export const init = async (): Promise => { appDataSource = new DataSource({ type: 'sqlite', database: path.resolve(homePath, 'database.sqlite'), - synchronize: process.env.OVERRIDE_DATABASE == 'true', + synchronize, entities: [ChatFlow, ChatMessage, Tool], migrations: [] }) diff --git a/packages/server/src/commands/start.ts b/packages/server/src/commands/start.ts index ffb6e44..d1287d2 100644 --- a/packages/server/src/commands/start.ts +++ b/packages/server/src/commands/start.ts @@ -20,13 +20,20 @@ export default class Start extends Command { FLOWISE_PASSWORD: Flags.string(), PORT: Flags.string(), DEBUG: Flags.string(), - DATABASE_PATH: Flags.string(), APIKEY_PATH: Flags.string(), LOG_PATH: Flags.string(), LOG_LEVEL: Flags.string(), EXECUTION_MODE: Flags.string(), TOOL_FUNCTION_BUILTIN_DEP: Flags.string(), - TOOL_FUNCTION_EXTERNAL_DEP: Flags.string() + TOOL_FUNCTION_EXTERNAL_DEP: Flags.string(), + OVERRIDE_DATABASE: Flags.string(), + DATABASE_TYPE: Flags.string(), + DATABASE_PATH: Flags.string(), + DATABASE_PORT: Flags.string(), + DATABASE_HOST: Flags.string(), + DATABASE_NAME: Flags.string(), + DATABASE_USER: Flags.string(), + DATABASE_PASSWORD: Flags.string() } async stopProcess() { @@ -61,7 +68,6 @@ export default class Start extends Command { if (flags.FLOWISE_USERNAME) process.env.FLOWISE_USERNAME = flags.FLOWISE_USERNAME if (flags.FLOWISE_PASSWORD) process.env.FLOWISE_PASSWORD = flags.FLOWISE_PASSWORD if (flags.PORT) process.env.PORT = flags.PORT - if (flags.DATABASE_PATH) process.env.DATABASE_PATH = flags.DATABASE_PATH if (flags.APIKEY_PATH) process.env.APIKEY_PATH = flags.APIKEY_PATH if (flags.LOG_PATH) process.env.LOG_PATH = flags.LOG_PATH if (flags.LOG_LEVEL) process.env.LOG_LEVEL = flags.LOG_LEVEL @@ -70,6 +76,16 @@ export default class Start extends Command { if (flags.TOOL_FUNCTION_BUILTIN_DEP) process.env.TOOL_FUNCTION_BUILTIN_DEP = flags.TOOL_FUNCTION_BUILTIN_DEP if (flags.TOOL_FUNCTION_EXTERNAL_DEP) process.env.TOOL_FUNCTION_EXTERNAL_DEP = flags.TOOL_FUNCTION_EXTERNAL_DEP + // Database config + if (flags.OVERRIDE_DATABASE) process.env.OVERRIDE_DATABASE = flags.OVERRIDE_DATABASE + if (flags.DATABASE_TYPE) process.env.DATABASE_TYPE = flags.DATABASE_TYPE + if (flags.DATABASE_PATH) process.env.DATABASE_PATH = flags.DATABASE_PATH + if (flags.DATABASE_PORT) process.env.DATABASE_PORT = flags.DATABASE_PORT + if (flags.DATABASE_HOST) process.env.DATABASE_HOST = flags.DATABASE_HOST + if (flags.DATABASE_NAME) process.env.DATABASE_NAME = flags.DATABASE_NAME + if (flags.DATABASE_USER) process.env.DATABASE_USER = flags.DATABASE_USER + if (flags.DATABASE_PASSWORD) process.env.DATABASE_PASSWORD = flags.DATABASE_PASSWORD + await (async () => { try { logger.info('Starting Flowise...')