Skip to content

Commit

Permalink
Fixing the actor
Browse files Browse the repository at this point in the history
  • Loading branch information
jancurn committed Dec 6, 2018
1 parent 5797755 commit 181e68e
Showing 1 changed file with 27 additions and 37 deletions.
64 changes: 27 additions & 37 deletions README.md
@@ -1,16 +1,20 @@
# apify/quick-start

This is a simple Apify act that contains the basic boilerplate
that you need when creating a new act hosted in a Git repository.
Fill free to copy it, change it and use it in your acts.
This is a simple Apify actor that contains the basic boilerplate
using a custom Dockerfile and hosted in a Git repository.
Fill free to copy it, change it and use it in your own actors.

Are you missing anything? Something not clear? Please let us know at support@apify.com

To run the act in your local environment, simply run the following commands:
To run the actor in your local environment, simply run the following commands:

```bash
npm install
npm run test-local
npm run start
```

Alternatively, if you have [Apify CLI](https://www.apify.com/docs/cli) installed, you can start the actor by running:

```bash
apify run
```

In order to test the build of the Docker image, run:
Expand All @@ -19,7 +23,7 @@ In order to test the build of the Docker image, run:
docker build ./
```

On success, the command will produce something like:
On success, the command will print something like:

```
...
Expand All @@ -34,12 +38,10 @@ Successfully built XYZ
After that you can run the built Docker image locally using:

```bash
docker run -e "APIFY_DEV_KEY_VALUE_STORE_DIR=./kv-store-dev/" XYZ
docker run XYZ
```

Where `XYZ` is ID of the Docker image built in the previous step.
Please see below for a detailed description of the `APIFY_DEV_KEY_VALUE_STORE_DIR`
environment variable.

If there is any problem with the built image, you might try troubleshooting it
by starting the container in interactive mode using:
Expand All @@ -54,7 +56,7 @@ Note that this requires a base Docker image that contains bash or some other int

## main.js

Contains the source code of the act in Node.js 7+.
Contains the source code of the actor in Node.js 7+.

## package.json

Expand All @@ -63,40 +65,28 @@ See [NPM docs](https://docs.npmjs.com/files/package.json) for more details.

## Dockerfile

Contains instructions for Docker how to build the image for the act.
Contains instructions for Docker how to build the image for the actor.
For more information, see [Dockerfile reference](https://docs.docker.com/engine/reference/builder/).

## README.md

The readme file is used to generate a long description of the act that is displayed in the
The readme file is used to generate a long description of the actor that is displayed in the
[Apify library](https://www.apify.com/apify/quick-start) as well as on the project's
[GitHub page](https://github.com/apifytech/act-quick-start).
[GitHub page](https://github.com/apifytech/actor-quick-start).

## apify_storage

## kv-store-dev
When running the actor on the Apify cloud, the actor is automatically assigned
a key-value store that is used to store actor's input, output or any other data.
The `apify_storage/key_value_stores/default` directory is used to emulate this storage
during the local development of your actor.

When running the act on the Apify cloud, the act is automatically assigned
a key-value store that is used to store act's input, output or any other data.
The `kv-store-dev` directory is used to emulate the key-value store
during local development of your act.
The files in the directory represent the records in the key-value store - the name
of each file corresponds to its key and the content to the value.

For example, calling `Apify.getValue('INPUT')` will return the content
of the `kv-store-dev/INPUT` file parsed as JSON. Similarly, calling
`Apify.setValue('OUTPUT', ...)` will write a file to `kv-store-dev/OUTPUT`.

To make this work, the reference to the `kv-store-dev` directory must be passed to the act process
as the `APIFY_DEV_KEY_VALUE_STORE_DIR` environment variable.
You can achieve that by starting the act using the following command:

```bash
npm run test-local
```

When reading the files from the directory, the `Apify.getValue()` function
assumes they have `application/json` content type and parses them to JSON.
If you want use a different content type, please set also
the `APIFY_DEV_KEY_VALUE_STORE_CONTENT_TYPE` environment variable.
of the `apify_storage/key_value_stores/default/INPUT.json` file parsed as JSON. Similarly, calling
`Apify.setValue('OUTPUT', ...)` will write a file to `apify_storage/key_value_stores/default/OUTPUT.json`.

For more information, see the
[apify NPM package documentation](https://www.apify.com/docs/sdk/apify-runtime-js/latest#module-Apify-getValue).
For more information, see the [Getting Started](https://sdk.apify.com/docs/guides/gettingstarted) tutorial
of the [Apify SDK](https://sdk.apify.com).

0 comments on commit 181e68e

Please sign in to comment.