docs/docs/get-started.md

3.2 KiB

Getting Started

  1. Open project folder in VS Code
  2. Create .env file
  3. Create database
  4. Create global admin
  5. Generate plugin repo
  6. Run app in VS Code

.env file

Create a new .env file in root folder. Refer to BaseConfig class in emgr/settings.py file for the variable names.

Set these variables for the host agent install script URL and plugin repo URL. Assuming your computer IP address is 192.168.0.2:

  • REPO_MIRRORS=["http://192.168.0.2:8080"]
  • BACKEND_URL=http://192.168.0.2:8000

These are default values for development:

  • OPENSEARCH_ADMIN_PASSWORD (default: mAckvusp5@)
  • POSTGRES_USER (default: em_db_user)
  • POSTGRES_PASSWORD (default: em_db_password)
  • POSTGRES_DB (default: em_db)

Create Global Admin

Run in devcontainer:

python cli.py create-admin --email admin@domain.com

Create database

Run in devcontainer:

reflex db init
reflex db makemigrations
reflex db migrate

Update database

If got changes to database schema, run in devcontainer:

reflex db makemigrations
reflex db migrate

Reset database

If want to reset database & start from scratch:

  1. Run in terminal (outside of devcontainer):
dropdb -U em_db_user em_db -h localhost -p 5432
createdb -U em_db_user em_db -h localhost -p 5432

Password is same as the POSTGRES_PASSWORD environment variable above. This command will drop & re-create the database.

  1. Run inside devcontainer:
rm -fr alembic* 
reflex db init 
reflex db makemigrations 
reflex db migrate

This will re-initialize the database table schema.

OpenSearch database indexes

OpenSearch database indexes are created automatically when the management tool push new data into the index.

Index list:

  • audit_log
  • cluster-metrics
  • deployment-metrics
  • host-metrics
  • host-logs
  • host-task-log

Delete OpenSearch index

Note: Run commands below outside of devcontainer. Replace {OPENSEARCH_ADMIN_PASSWORD} with actual value from environment variable above.

To delete one index, e.g host-metrics:

curl -X DELETE -u admin:{OPENSEARCH_ADMIN_PASSWORD} -k https://localhost:9200/host-metrics

To delete multiple indexes, specify as comma-separated values:

curl -X DELETE -u admin:{OPENSEARCH_ADMIN_PASSWORD} -k https://localhost:9200/audit_log,cluster-metrics,deployment-metrics,host-metrics,host-logs,host-task-log

Generate plugin repository

Run in devcontainer:

python cli.py build-repo

The repository metadata file can be accessed at http://localhost:8080/metadata.json

Run app in VS Code

To run in development mode, either:

  • Ctrl + Shift + P > Run Task > Run, or
  • Run in devcontainer: reflex run

To run in production mode, run in devcontainer:

reflex run --env prod

Devcontainer Components URL

Container Component URL
Reflex Frontend http://localhost:3000
Backend http://localhost:8000
Swagger http://localhost:8000/docs
Opensearch API https://localhost:9200
Dashboard http://localhost:5601
Nginx Plugin repo http://localhost:8080