-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f7a65e
commit 5795b26
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
title: "Vendure Worker" | ||
weight: 0 | ||
showtoc: true | ||
--- | ||
|
||
# Vendure Worker | ||
|
||
The Vendure Worker is a process which is responsible for running computationally intensive or otherwise long-running tasks in the background. For example updating a search index or performing image transformations. | ||
|
||
The worker is started by calling the `bootstrapWorker()` function with the same configuration as is passed to the main server `bootstrap()`: | ||
|
||
```TypeScript | ||
import { bootstrapWorker } from '@vendure/core'; | ||
|
||
import { config } from './vendure-config'; | ||
|
||
bootstrapWorker(config).catch(err => { | ||
console.log(err); | ||
}); | ||
``` | ||
|
||
## Underlying architecture | ||
|
||
Internally, the Worker is an instance of a [NestJS microservice](https://docs.nestjs.com/microservices/basics). By default the TCP protocol is used to send messages to and receive reponses from the Worker, but other transports may be used such as Redis or gRPC. | ||
|
||
## Running on the main process | ||
|
||
There is an option `runInMainProcess` which, if set to `true` will cause the Worker to be bootstrapped along with the main application, without the need for a separate process running `bootstrapWorker`. This is mainly used for testing and development, and is not advised for production use, since it negates the benefits of running long tasks off of the main process. |