/compute.rhino3d

REST geometry server based on RhinoCommon and headless Rhino

Primary LanguageC#

Rhino Compute Server

Build status Discourse users

A REST api exposing Rhino's geometry core. This project has two web services: compute.geometry which provides the REST API, and compute.frontend that provides authentication, request stashing (saving POST data for diagnostics), logging, and configuration of request and response headers. compute.frontend creates the compute.geometry process, monitors its health, and restarts compute.geometry as necessary.

Getting Started

  1. Get the latest build from the master branch (or build from source).
  2. Create a Windows Server 2016 computer.
  3. Remote desktop onto server.
  4. Copy src/bin/Release to the server.
  5. Install Rhino using PowerShell* (as administrator):
    • In PowerShell: cd _C:\Users\[USERNAME]\Desktop\Release\deployment\_.
    • Run the admin script using: .\headless_admin.ps1 -updaterhino. This will download the Rhino installer and place it in the deployment directory.
    • Once downloaded, double-click on rhinoinstaller.exe and install like you typically would.
  6. Run and license Rhino. Be sure to validate your license.
  7. Open cmd.exe, cd to the Release directory and run compute.frontend.exe.
  8. For next steps, see Configuration and Running Compute as a service.

* We include a PowerShell script to make easy to download Rhino on Windows Server with it's strict default internet security settings.

Configuration

URL reservation

Release builds of Compute listen on all available IP addreses by default. For this to work, you must:

  1. Start PowerShell as Administrator.
  2. For HTTP, netsh http add urlacl url="http://+:80/" user="Everyone".
  3. For HTTPS, netsh http add urlacl url="https://+:443/" user="Everyone".

Environment variables

All configuration of Compute is done via environment variables.

Environment variable Type Default Description
COMPUTE_HTTP_PORT integer 80 (Release), 8888 (Debug) Port to run HTTP server
COMPUTE_HTTPS_PORT integer 0 Port to run HTTPS server
COMPUTE_SPAWN_GEOMETRY_SERVER bool true (Release), false (Debug) When True, compute.frontend will spawn compute.geometry at http://localhost on port COMPUTE_BACKEND_PORT. Defaults to false in Debug so that you can run both compute.geometry and compute.frontend in the debugger. Configure this in Solution > Properties > Startup Project.
COMPUTE_BACKEND_PORT integer 8081 Sets the TCP port where compute.geometry runs.
COMPUTE_AUTH_METHOD string RHINO_ACCOUNT: Enables authentication via Rhino Accounts OAuth2 Token. Get your token at https://www.rhino3d.com/compute/login and pass it using a Bearer Authentication header in your HTTP request: Authorization: Bearer <YOUR TOKEN>.
API_KEY: Enables athentication via simple API key that looks like an email address.
COMPUTE_LOG_RETAIN_DAYS integer 10 Delete log files after 10 days.
COMPUTE_LOG_CLOUDWATCH bool false Stream logs to Amazon CloudWatch.
COMPUTE_STASH_METHOD string TEMPFILE TEMPFILE: Enables stashing POST input data to a temp file.
AMAZONS3: Enables stashing POST input data to an Amazon S3 bucket.
COMPUTE_STASH_S3_BUCKET string Name of the Amazon S3 bucket where POST input data should be stashed. Requires COMPUTE_STASH_METHOD=AMAZONS3
AWS_ACCESS_KEY string Amazon Web Services Access Key for your account. If compute is running on EC2, consider using EC2 Instance Profiles; Compute will find and use your credentials so they don't need to be on your instance.
AWS_SECRET_ACCESS_KEY string Amazon Web Services Secrete Access Key for your account. If compute is running on EC2, consider using EC2 Instance Profiles; Compute will find and use your credentials so they don't need to be on your instance.
AWS_REGION_ENDPOINT string "us-east-1" Amazon Web Services Region Endpoint

SSL certificate (optional)

Add LetsEncrypt SSL Certificate for HTTPS support:

  • Download from https://github.com/PKISharp/win-acme/releases/tag/v1.9.8.4
  • Unzip download on the server.
  • Start PowerShell as Administrator.
  • cd to unzipped directory.
  • .\letsencrypt.exe
  • N create new certificate.
  • 4 manually input host names.
  • compute.rhino3d.com (or similar)
  • 1 for default web site.
  • you@yourdomain.com for the user to receive issues.
  • yes to accept the license agreement.
  • Q to Quit.

Running Compute as a service

Compute uses TopShelf to make it easy to configure and run it as a service on Windows.

  1. Start cmd.exe as Administrator.
  2. In cmd: cd C:\Users\[USERNAME]\Desktop\Release\
  3. Run compute.frontend install to install as a service.
  4. In the interactive menu, enter your username in the format .\\[USERNAME] (for example:.\steve) and use the administrator password for this account.

Building from source

  1. Install Rhino WIP.
  2. Start Rhino WIP to configure its license.
  3. Load compute.sln and compile as Debug.
  4. In Solution Explorer, right-click Solution 'compute', then click Properties
  5. In the Startup Project tab, select Multiple Startup Projects, then set both compute.frontend and compute.geometry to Start.
  6. Start the application in the debugger.
  7. Browse to http://localhost:8888/version or http://localhost:8888/sdk

Notes

  • There is a health check URL (/healthcheck) in case you want to set up a load balancer