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 --helpUsage
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 Node.js worker processes responsible for handling HTTP requests to the web server. By default, Gigantics runs with a single web worker in the main process. You can fork additional worker processes to handle more concurrent requests and improve performance:
# Fork 4 web worker processes for better concurrency
gig start -w=4When 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 are Node.js worker processes that 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:
# Fork 6 job worker processes for background processing
gig start -j=6Job 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]- Fork web worker processes-j, --job [workers]- Fork job worker processes--logLevel [level]- Override the logging level
Examples
Basic Start
# Start Gigantics with default configuration
gig startThis 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.yamlRunning 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=8080This 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 Worker Forking for Performance
# Fork 4 web worker processes
gig start -w=4With the -w option, you fork 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=debugSetting --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=2Getting Help
As with all Gigantics commands, you can get detailed help information:
gig start --helpThis 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
-
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.
-
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
-
Daemon Mode in Production: When deploying in production, use the
-dflag to run the server in the background to ensure continuous operation. -
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
- Don't expose the server to all interfaces (
-
Logging: Use appropriate log levels for each environment:
- Development: info or debug levels for troubleshooting
- Production: warn or error levels to reduce log volume