Administration/Configuration Files

Environment Configuration

Configure the environment settings for your Gigantics instance. These settings control how the application behaves based on the deployment environment.

Environment Variable

The primary environment configuration is controlled by the NODE_ENV environment variable:

# This is typically not set in the YAML file but controlled by environment
# NODE_ENV can be 'development', 'production', or 'test'

Environment Detection

The application automatically detects the environment and adjusts behavior accordingly:

  • Development: Enhanced logging, debugging features enabled
  • Production: Optimized performance, minimal logging
  • Test: Special test configurations, minimal output

Setting the Environment

Using Environment Variables

# Set environment to production
export NODE_ENV=production
./gig start
 
# Set environment to development
export NODE_ENV=development
./gig start
 
# Set environment to test
export NODE_ENV=test
./gig start

Using Command Line

# Start in development mode
NODE_ENV=development ./gig start
 
# Start in production mode
NODE_ENV=production ./gig start
 
# Start in test mode
NODE_ENV=test ./gig start

Windows Command Line

# Set environment variable on Windows
set NODE_ENV=production
gig.exe start
 
# Or set it for just one command
set NODE_ENV=production && gig.exe start

Environment-Specific Behaviors

Development Environment

  • Default encryption key: 'my-secret-key'
  • Log level: 'silly'
  • Enhanced debugging output
  • Development SMTP credentials

Production Environment

  • Generates secure random encryption key
  • Log level: 'http'
  • Optimized performance settings
  • Requires proper SMTP configuration

Test Environment

  • Special test configurations
  • Log level: 'test'
  • Isolated test settings

Environment Methods

The application provides methods to check the current environment:

  • env.isProduction() - Returns true if NODE_ENV is 'production'
  • env.isDevelopment() - Returns true if NODE_ENV is 'development'
  • env.isTest() - Returns true if NODE_ENV is 'test'

Best Practices

  1. Always Set Environment: Explicitly set NODE_ENV in production
  2. Environment Consistency: Ensure all application components run in the same environment
  3. Configuration by Environment: Use different configuration files for different environments
  4. Security: Never use development settings in production

Testing Environment Configuration

To verify environment configuration:

  1. Check current environment:

    echo $NODE_ENV
  2. Start application with specific environment:

    NODE_ENV=development ./gig start
  3. Check logs to verify environment-specific settings are applied

Using Multiple Configuration Files

You can create environment-specific configuration files:

  • config/default.yaml - Base configuration
  • config/development.yaml - Development overrides
  • config/production.yaml - Production overrides
  • config/test.yaml - Test overrides

Start with specific configuration files:

# Use development configuration
./gig start -c config/development.yaml
 
# Use production configuration
./gig start -c config/production.yaml