Skip to content

Commit

Permalink
feat: Improve Standby docs (#1150)
Browse files Browse the repository at this point in the history
There were some questions on Discord how to find out if an Actor is
started in Standby mode, or normally. This should answer them.

I've also added a tip about Standby in the Container web server docs.

This needs apify/apify-sdk-js#320 released.
  • Loading branch information
fnesveda authored Aug 19, 2024
1 parent 0bfe8c6 commit e1d2d31
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,44 @@ async def main() -> None:
Please make sure to describe your Actors, their endpoints, and the schema for their
inputs and outputs in your README.

## How do I find out whether my Actor is started in Standby or standard mode

Actors that support Actor Standby can still be started in standard mode, for example from the Console or via the API.
To find out in which mode was the Actor started, you can read the `metaOrigin` option in `Actor.config`, or the `APIFY_META_ORIGIN` environment variable in case you're not using the Apify SDK.
If it is equal to `STANDBY`, the Actor was started in Standby mode, otherwise it was started in standard mode.

<Tabs groupId="main">
<TabItem value="JavaScript" label="JavaScript">

```js
import { Actor } from 'apify';

await Actor.init();

if (Actor.config.get('metaOrigin') === 'STANDBY') {
// Start your Standby server here
} else {
// Perform the standard Actor operations here
}
```

</TabItem>
<TabItem value="Python" label="Python">

```python
from apify import Actor

async def main() -> None:
async with Actor:
if Actor.config.meta_origin == 'STANDBY':
# Start your Standby server here
else:
# Perform the standard Actor operations here
```

</TabItem>
</Tabs>

## Can I monetize my Actor in the Standby mode

No, Standby mode is in Beta, and monetization is not supported.
No, Standby mode is in Beta, and monetization is currently not supported.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ import TabItem from '@theme/TabItem';

Each Actor run is assigned a unique URL (e.g. `kmdo7wpzlshygi.runs.apify.net`) that allows HTTP access to an optional web server running inside the Actor's Docker container. This feature enhances your Actor's capabilities by enabling external communication.

:::tip Using Actors as an API

The container web server provides a way how to connect to one specific Actor run. To enable using your Actor as an API, with a pre-defined hostname, load balancing and autoscaling, check out [Actor Standby](./actor_standby.md).

:::

## Access the container URL

You can find the container URL in three locations:
Expand Down
1 change: 1 addition & 0 deletions sources/platform/actors/running/runs_and_builds.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ All **Actor runs** have an **Origin** field indicating where the Actor run was i
|SCHEDULER|Using a Schedule|
|WEBHOOK|Using a webhook|
|ACTOR|From another Actor run|
|STANDBY|From Actor Standby|

## Lifecycle

Expand Down

0 comments on commit e1d2d31

Please sign in to comment.