Skip to content

Commit f468a49

Browse files
committed
feat: add standby URL, changes to port unification
1 parent eb7a498 commit f468a49

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

sources/platform/actors/development/programming_interface/actor_standby.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ If you already have an existing Actor, or you just want to tweak the configurati
2525

2626
Actors using Standby mode must run a HTTP server listening on a specific port. The user requests will then be proxied to the HTTP server. You can use any of the existing [HTTP request methods](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) like GET, POST, PUT, DELETE, etc. You can pass the input via [HTTP request query string](https://en.wikipedia.org/wiki/Query_string) or via [HTTP request body](https://developer.mozilla.org/en-US/docs/Web/HTTP/Messages#body).
2727

28-
Sometimes, you want the HTTP server to listen on a specific port and cannot change it yourself. You can use `ACTOR_STANDBY_PORT` environment variable to override the port so that Actor Standby will work with your code.
28+
Sometimes, you want the HTTP server to listen on a specific port and cannot change it yourself. You can use `ACTOR_WEB_SERVER_PORT` environment variable to override the port so that Actor Standby will work with your code.
2929

3030
You can get the port using the Actor configuration available in Apify SDK.
3131
See example below with a simple Actor using Standby mode.
@@ -44,7 +44,7 @@ const server = http.createServer((req, res) => {
4444
res.end('Hello from Actor Standby!\n');
4545
});
4646

47-
server.listen(Actor.config.get('standbyPort'));
47+
server.listen(Actor.config.get('containerPort'));
4848
```
4949

5050
</TabItem>
@@ -62,7 +62,7 @@ class GetHandler(SimpleHTTPRequestHandler):
6262

6363
async def main() -> None:
6464
async with Actor:
65-
with HTTPServer(('', Actor.config.standby_port), GetHandler) as http_server:
65+
with HTTPServer(('', Actor.config.web_server_port), GetHandler) as http_server:
6666
http_server.serve_forever()
6767
```
6868

@@ -110,6 +110,10 @@ async def main() -> None:
110110
</TabItem>
111111
</Tabs>
112112

113+
## Getting the URL of the Standby Actor
114+
115+
The URL is exposed as an environment variable `ACTOR_STANDBY_URL`. You can also use `Actor.config`, where the `standbyUrl` option is available.
116+
113117
## Monetization of Actors with the Standby mode?
114118

115119
Currently, the Standby mode is in beta, and monetization is not supported. But we plan to enable it soon.

sources/platform/actors/development/programming_interface/environment_variables.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ Here's a table of key system environment variables:
3939
| `APIFY_PROXY_PASSWORD` | Password for accessing Apify Proxy services. This password enables the Actor to utilize proxy servers on behalf of the user who initiated the Actor run. |
4040
| `APIFY_PROXY_PORT` | TCP port number to be used for connecting to the Apify Proxy. |
4141
| `APIFY_PROXY_STATUS_URL` | URL for retrieving proxy status information. Appending `?format=json` to this URL returns the data in JSON format for programmatic processing. |
42-
| `ACTOR_STANDBY_PORT` | TCP port for the Actor to start an HTTP server to receive messages in the [Actor Standby](/platform/actors/development/programming-interface/standby) mode. |
42+
| `ACTOR_STANDBY_URL` | URL for accessing web servers of Actor runs in the [Actor Standby](/platform/actors/development/programming-interface/standby) mode. |
4343
| `ACTOR_STARTED_AT` | Date when the Actor was started. |
4444
| `ACTOR_TIMEOUT_AT` | Date when the Actor will time out. |
4545
| `APIFY_TOKEN` | API token of the user who started the Actor. |
4646
| `APIFY_USER_ID` | ID of the user who started the Actor. May differ from the Actor owner. |
47-
| `ACTOR_WEB_SERVER_PORT` | TCP port for the Actor to start an HTTP server on. This server can be used to receive external messages or expose monitoring and control interfaces. |
47+
| `ACTOR_WEB_SERVER_PORT` | TCP port for the Actor to start an HTTP server on. This server can be used to receive external messages or expose monitoring and control interfaces. The server also receives messages from the [Actor Standby](/platform/actors/development/programming-interface/standby) mode. |
4848
| `ACTOR_WEB_SERVER_URL` | Unique public URL for accessing the Actor run web server from the outside world. |
4949
| `APIFY_API_PUBLIC_BASE_URL` | Public URL of the Apify API. May be used to interact with the platform programmatically. Typically set to `api.apify.com`. |
5050
| `APIFY_DEDICATED_CPUS` | Number of CPU cores reserved for the actor, based on allocated memory. |

0 commit comments

Comments
 (0)