Administration/Command Line

Start Command

The gig start command is used to start the Gigantics server and all related services. This command initializes the application and can be configured to run in various modes including daemon mode, with different worker configurations, and with custom settings for hostname, port, and logging.

You can get detailed help for this command by running:

gig start --help

Usage

gig start [options]

Description

The start command initializes and starts all Gigantics services. This includes the web server, job workers, and any other configured services.

Worker Processes

Gigantics supports two types of worker processes to improve performance and handle concurrent operations:

Web Workers (-w, --web)

Web workers are responsible for handling HTTP requests to the web server. By default, Gigantics runs with a single web worker. You can scale up the number of web workers to handle more concurrent requests and improve performance:

# Start with 4 web workers for better concurrency
gig start -w=4

When using web workers, each worker process handles incoming requests independently. This is particularly useful in production environments with high traffic loads.

Job Workers (-j, --job)

Job workers handle background tasks and asynchronous operations within Gigantics. These workers process tasks from the job queue, such as sending emails, processing files, or performing database maintenance:

# Start with 6 job workers for background processing
gig start -j=6

Job workers are essential for maintaining responsive user experience when the application needs to perform time-consuming operations.

Common Options

  • -d, --daemon - Run the server as a daemon process in the background
  • -c, --config [path] - Specify the configuration file path
  • --hostname [hostname] - Override the server hostname
  • --port [port] - Override the server port
  • -w, --web [workers] - Start web workers (cluster mode)
  • -j, --job [workers] - Start job workers
  • --logLevel [level] - Override the logging level

Examples

Basic Start

# Start Gigantics with default configuration
gig start

This command starts the Gigantics server with the default settings defined in the configuration file. The server will bind to the hostname and port specified in your config file, typically localhost:3000 for development environments.

Daemon Mode

# Start in daemon mode with specific config
gig start -d -c config/production.yaml

Running with the -d or --daemon flag starts the server as a background process. This is useful for production environments where you want the server to continue running even after you close your terminal session. The -c flag allows you to specify which configuration file to use.

Custom Network Settings

# Start with custom hostname and port
gig start --hostname=0.0.0.0 --port=8080

This example overrides the default hostname and port settings. Using --hostname=0.0.0.0 makes the server accessible from any network interface, not just localhost. This is often used in containerized environments or when you need to access the server from other machines.

Web Clustering for Performance

# Start with web clustering
gig start -w=4

With the -w option, you start multiple web worker processes (in this case, 4 workers). Each worker can handle requests independently, which improves the application's ability to handle concurrent users. This is recommended for production environments with high traffic.

Debugging and Logging

# Start with debug logging
gig start --logLevel=debug

Setting --logLevel=debug enables detailed logging output, which is helpful for troubleshooting issues during development. Other available log levels include error, warn, info, http, and verbose, each providing different amounts of detail.

Combining Options

You can combine multiple options to customize your server startup:

# Start server in daemon mode with custom config, 4 web workers, and debug logging
gig start -d -c config/production.yaml -w=4 --logLevel=debug
 
# Start server accessible on all interfaces with custom port and 2 job workers
gig start --hostname=0.0.0.0 --port=8080 -j=2

Getting Help

As with all Gigantics commands, you can get detailed help information:

gig start --help

This will display all available options with their descriptions and default values.

Environment Variables

The start command respects these environment variables:

  • NODE_ENV - Environment mode (development, production, test)
  • GIGANTICS_CONFIG - Configuration file path

Best Practices

  1. Development vs Production: Use different configuration files for development and production environments. The default configuration is suitable for development, but production environments should use optimized settings.

  2. Worker Configuration:

    • For development: Use a single web worker for easier debugging
    • For production: Adjust the number of web workers based on CPU cores (typically 1-2 workers per core)
    • Job workers: Configure based on your application's background task load
  3. Daemon Mode in Production: When deploying in production, use the -d flag to run the server in the background to ensure continuous operation.

  4. Security Considerations:

    • Don't expose the server to all interfaces (0.0.0.0) unless necessary
    • Use environment variables for sensitive configuration instead of command line arguments
    • Ensure proper firewall configuration in production environments
  5. Logging: Use appropriate log levels for each environment:

    • Development: info or debug levels for troubleshooting
    • Production: warn or error levels to reduce log volume

See Also

On this page