README
Cacher Run Server

The Cacher Run Server is a standalone Socket.io-based server that allows clients to run shell commands via Websocket messages. It is used primarily to run code snippets on the user's local machine via Cacher.
Demo of a Cacher snippet file executing on a Run Server:

Contents
Starting the Server
Built-in Mode
The Cacher Desktop Client comes with the Run Server built-in. Open the Run Server dialog and click Start Server:

Standalone Mode
Start the Run Server in standalone mode if you require more control over its configuration.
Using the Cacher CLI
Start server locally
npm i -g @cacherapp/cli
cacher run-server:start
Starting the server on a remote machine
Running a remote server ensures all your developers are able to run snippet file commands against the same environment.
Note: Since the commands will be run using the shell account from which you launch the CLI, we recommend you use only machines which are for testing or are ephemeral (i.e. Docker instances).
Example of launching with a secure tunnel (ngrok).
npm i -g @cacherapp/cli
cacher run-server:start -p 39135 -t 4D5dzRGliafhGg~btNlR9 -o file:// -v
ngrok http 39135
Start via custom script
Install run-server package for your Node project.
npm i --save @cacherapp/run-server
Examples of starting the Run Server:
// examples.js
const RunServer = require('@cacherapp/run-server').RunServer;
// Let server pick random port and token
(new RunServer(
{ origin: 'https://app.cacher.io' }
)).start();
// Specify port and token, log verbose output to file
(new RunServer(
{
origin: 'file://',
port: 43193,
token: 'secret_token',
verbose: true,
logToFile: true
}
)).start();
See server.model.ts for details on options.
Connecting to the standalone server
You'll need either the Cacher Web App or the Desktop Client in order to connect to a standalone Run Server.
Once you've logged in, open the Run Server dialog. Input your server's port and token and press Connect.

Editing the Configuration
The Run Server uses two Javascript-based config files to define the set of rules which govern how different file extensions are mapped to shell commands:
config.default.js - The default set of file types -> shell command mappings. While this config is copied to the Cacher directory as
~/.cacher/run-server.config.js, you should never edit this file. If you would like to add a file handler to this config (and let everyone use it), please submit a pull request instead. See the Contributing section below.~/.cacher/run-server.user-config.js- Edit this file to add or overwrite file extension handlers on your local machine. Here are some examples of functions you might add to handle new file types:
Add command for .awesome file extension.
// ~/.cacher/run-server.user-config.js
return {
rules: [
{
pattern: '\.awesome