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:
Usage
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:
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:
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
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
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
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
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
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:
Getting Help
As with all Gigantics commands, you can get detailed help information:
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
-
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