Workers
Each running App has the ability to run a worker process(Background worker). Workers are a powerful tool for running long-running tasks or asynchronous processes in the background, without blocking the main application thread.
Background workers are independent processes that execute tasks in the background, separate from the primary application code. This allows your application to remain responsive to user requests while workers handle time-consuming or resource-intensive operations. Hostless provides a framework for creating, managing, and monitoring worker processes.
This documentation explains the concept of background workers within the Hostless provider application.
Creating a worker process
Hostless offers a general approach to create worker processes depending on your programming language and preferences. Here's a general overview:
- Navigate to the
Worker
tab on the app view - Click on
Create New Worker
- Assuming the code for your worker process already exist in your linked repo, define you command to start the worker process
- Give your worker process a name
- You can adjust the Replicas, Memory and CPU Usage of your worker app depending on your desired configurations
- Click on
Create Worker Process
Please note: Some programming languages may require more memory and vCPUs to run/start compared to the default configurations. If your application does not start, you can still edit this configurations
Accessing worker process
Hostless provides a user interface for managing and monitoring your worker processes. You can access this interface to view:
- List of Workers: This view displays a comprehensive list of all currently registered worker processes within your Hostless app environment. It shows information like worker name, status (running, queued, or stopped), and worker ids.
- Single Worker logs: Selecting a specific worker from the list allows you to drill down and see detailed information about that particular worker. This view includes the logs for the worker process
Modifying a worker process
Editing a worker process typically involves:
- Click
Edit Worker
on the target worker from the list of workers in theWorkers
tab. - Modifying the desired parameters, such as CPU allocation, memory allocation, replicas, worker name, worker start command or environment variables.
- Saving the changes.
Please note: Changes to worker configurations will restart the worker process for the new configuration to take effect.
Example project: