Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

There are a few things that will make managing your pico engine and writing KRL code easier. 

...

Update to the Latest Version

You can update to the latest version using the command

Code Block
npm update -g pico-engine

Check Your Version

You can see which version you are using near the top-left corner of the "My Picos" page (localhost:8080) or by running the command

Code Block
npm ls -g pico-engine

...

Code Block
PORT=8081 
PICO_ENGINE_HOME=~/.pico-engine-1 pico-engine


Running Your Engine In Dev vs Production Mode

There are a few ways to start the pico engine. If you globally installed it, the command is simply "pico-engine". If you cloned the engine from github, then you can use "npm start" from the cloned folder root, or run the cli.js file located in packages/pico-engine/src. The "npm start" command uses a different database than directly running the cli.js file. The "npm start" method creates a database located in packages/pico-engine, whereas the cli.js file creates a database at the location where the pico-engine root folder exists. This second database is under a folder called ".pico-engine". The first method is considered to be a dev mode, whereas the latter is a production mode.

When hosting your engine an a hosting server, like AWS or Digital Ocean, you may use a tool like forever to keep the engine running even when you close your ssh connected terminal. Running the command "npm start" using forever tends to have trouble, and we must run the cli.js file as described above, like this:

Code Block
forever start packages/pico-engine/src/cli.js


This uses a different database from development mode as described above, so if you need to use the same database for some reason, then you need to specify its location like this:

Code Block
PICO_ENGINE_HOME=/home/pi/pico-engine/packages/pico-engine forever start /home/pi/pico-engine/packages/pico-engine/src/cli.js

Please note that this absolute path works on a raspberry pi 3, and will likely not be the exact same path if you are running an engine on windows/mac/linux. Try running the engine at least once to create the database, then find the absolute path to use in the forever command.

Hosting Code

Because the rules engine reads your KRL program from the Web, it has to be available online. You can host it anywhere. There are a few options:

  1. GitHub works well, with one caveat. See these instructions for more information about how to use GitHub to host KRL. The caveat is that GitHub caches the resources on raw URLs for about 5 minutes. If you're making frequent changes, it can be frustrating to wait out the cache. Alternatively, GitLab should give you fewer caching problems. (raw URLs to rulesets in private repositories need an account access token)
  2. AWS S3 works well. Be sure to make the URL for the ruleset is readable by the engine. 

...