Configuration
Index
Constructors
constructor
Creates new
Configurationinstance with provided options. Env vars will have precedence over those.Parameters
options: ConfigurationOptions = {}
Returns Configuration
Properties
publicreadonlystorageManagers
Methods
get
Returns configured value. First checks the environment variables, then provided configuration, fallbacks to the
defaultValueargument if provided, otherwise uses the default value as described in the above section.Parameters
key: T
optionaldefaultValue: U
Returns U
getEventManager
Returns EventManager
set
Sets value for given option. Only affects this
Configurationinstance, the value will not be propagated down to the env var. To reset a value, we can omit thevalueargument or passundefinedthere.Parameters
key: keyof ConfigurationOptions
optionalvalue: any
Returns void
useEventManager
Parameters
events: EventManager
Returns void
useStorageClient
Parameters
client: StorageClient
Returns void
staticgetEventManager
Gets default EventManager instance.
Returns EventManager
staticgetGlobalConfig
Returns the global configuration instance. It will respect the environment variables.
Returns Configuration
staticgetStorageClient
Gets default StorageClient instance.
Returns StorageClient
staticresetGlobalState
Resets global configuration instance. The default instance holds configuration based on env vars, if we want to change them, we need to first reset the global state. Used mainly for testing purposes.
Returns void
staticset
Sets value for given option. Only affects the global
Configurationinstance, the value will not be propagated down to the env var. To reset a value, we can omit thevalueargument or passundefinedthere.Parameters
key: keyof ConfigurationOptions
optionalvalue: any
Returns void
staticuseStorageClient
Parameters
client: StorageClient
Returns void
Configurationis a value object holding Crawlee configuration. By default, there is a global singleton instance of this class available viaConfiguration.getGlobalConfig(). Places that depend on a configurable behaviour depend on this class, as they have the global instance as the default value.Using global configuration:
Using custom configuration:
The configuration provided via environment variables always takes precedence. We can also define the
crawlee.jsonfile in the project root directory which will serve as a baseline, so the options provided in constructor will override those. In other words, the precedence is:Supported Configuration Options
memoryMbytesCRAWLEE_MEMORY_MBYTESlogLevelCRAWLEE_LOG_LEVELheadlessCRAWLEE_HEADLESStruedefaultDatasetIdCRAWLEE_DEFAULT_DATASET_ID'default'defaultKeyValueStoreIdCRAWLEE_DEFAULT_KEY_VALUE_STORE_ID'default'defaultRequestQueueIdCRAWLEE_DEFAULT_REQUEST_QUEUE_ID'default'persistStateIntervalMillisCRAWLEE_PERSIST_STATE_INTERVAL_MILLIS60_000purgeOnStartCRAWLEE_PURGE_ON_STARTtruepersistStorageCRAWLEE_PERSIST_STORAGEtrueAdvanced Configuration Options
inputKeyCRAWLEE_INPUT_KEY'INPUT'xvfbCRAWLEE_XVFBchromeExecutablePathCRAWLEE_CHROME_EXECUTABLE_PATHdefaultBrowserPathCRAWLEE_DEFAULT_BROWSER_PATHdisableBrowserSandboxCRAWLEE_DISABLE_BROWSER_SANDBOXavailableMemoryRatioCRAWLEE_AVAILABLE_MEMORY_RATIO0.25systemInfoV2CRAWLEE_SYSTEM_INFO_V2