A daemon process is a program that runs in the background, other than one under the direct control of users. The Hvigor daemon process is a persistent background process that helps to reduce the build time.
The Hvigor client sends build information such as command line arguments, project directories, and environment variables to the daemon process to facilitate build execution. The communication between the client and daemon process is conducted through a local socket connection. A maximum of eight daemon processes can run concurrently. Among these, no more than six processes can be in the active state (that is, neither stopped nor interrupted).
Usage of the daemon process is enabled in Hvigor by default. You can manage the settings using the following methods:
// Enable usage of the daemon process. hvigorw <task> --daemon // Disable usage of the daemon process. hvigorw <task> --no-daemon
The maximum old-generation memory allocated to the daemon process defaults to 8192 MB, which is sufficient for most builds. To customize the maximum old-generation memory for the daemon process, use either of the following methods. Adjust the settings based on your available local memory. The command-line option takes precedence over the hvigor-config.json5 configuration.
hvigorw assembleHap --max-old-space-size=12345
The maximum semi-space size of the young-generation memory for the daemon process defaults to 16 MB. By modifying this value, you can control garbage collection frequency, which directly impacts performance and memory usage. You can use either of the following methods to modify the settings. The CLI method has a higher priority than the hvigor-config.json5 file.
This feature is supported since DevEco Studio 5.1.0 Release.
hvigorw assembleHap --max-semi-space-size=32
The default idle timeout for the daemon process is three hours, counted from the completion of the last build task. The daemon process exits once this duration is exceeded. Since version 26.0.0, the daemon idle timeout can be customized. Two methods are supported, with the command-line option taking precedence over the hvigor-config.json5 configuration:
hvigorw assembleHap -c properties.hvigor.daemon.idleTimeout=10800000
To get a list of running daemon processes and their status, you can use the following command:
hvigorw --status-daemon
> hvigor PID STATUS PORT ROOT_PATH > hvigor 11072 idle 45001 D:\Demo1 > hvigor 18836 stopped 45000 D:\Demo2
Status | Description |
|---|---|
idle | Idle |
half_busy | Half busy |
busy | Busy |
canceled | Canceled |
stopReq | Stopped as requested. |
stopped | Stopped |
broken | Interrupted |
It is necessary to restart a daemon process when changing the memory settings or debugging faults.
You can use the following command to stop a daemon process:
hvigorw --stop-daemon
If you want to stop all daemon processes, run the following command:
hvigorw --stop-daemon-all