### Quick Setup Source: https://github.com/mcneel/compute.rhino3d/blob/9.x/package/SYSTEMD_SERVICE.md Enable the service to start on boot and start it immediately. ```bash # Enable service to start on boot sudo systemctl enable rhino-compute # Start the service now sudo systemctl start rhino-compute ``` -------------------------------- ### Copy example configuration Source: https://github.com/mcneel/compute.rhino3d/blob/9.x/package/SYSTEMD_SERVICE.md Copy the example environment configuration file. ```bash sudo cp /etc/rhino-compute/environment.example /etc/rhino-compute/environment ``` -------------------------------- ### Start rhino-compute service Source: https://github.com/mcneel/compute.rhino3d/blob/9.x/package/SYSTEMD_SERVICE.md Command to start the rhino-compute service. ```bash /usr/bin/rhino-compute-start ``` -------------------------------- ### Custom configuration example Source: https://github.com/mcneel/compute.rhino3d/blob/9.x/package/SYSTEMD_SERVICE.md Example of custom configuration for the systemd service, changing the listening URL and child count. ```ini [Service] ExecStart= ExecStart=/usr/bin/rhino-compute --urls http://0.0.0.0:8080 --childcount 8 ``` -------------------------------- ### Install Flask Source: https://github.com/mcneel/compute.rhino3d/blob/9.x/src/ghhops-server-py/README.md Installs the Flask web framework, which is used as the HTTP server. ```shell pip install flask ``` -------------------------------- ### Troubleshooting: Verify rhino3d installation Source: https://github.com/mcneel/compute.rhino3d/blob/9.x/package/SYSTEMD_SERVICE.md Verify if rhino3d is installed on the system. ```bash # On RPM-based systems rpm -q rhino3d # On Debian-based systems dpkg -l rhino3d ``` -------------------------------- ### Install rhino-compute Source: https://github.com/mcneel/compute.rhino3d/blob/9.x/package/SYSTEMD_SERVICE.md Install rhino-compute using the system's package manager. ```bash sudo dnf install rhino-compute # On Ubuntu sudo apt install rhino-compute ``` -------------------------------- ### View Logs Source: https://github.com/mcneel/compute.rhino3d/blob/9.x/package/SYSTEMD_SERVICE.md View logs for the rhino-compute service. ```bash # Follow logs in real-time sudo journalctl -u rhino-compute -f # View recent logs sudo journalctl -u rhino-compute -n 100 ``` -------------------------------- ### Troubleshooting: Test manual startup Source: https://github.com/mcneel/compute.rhino3d/blob/9.x/package/SYSTEMD_SERVICE.md Test manual startup of the rhino-compute service as the dedicated user. ```bash sudo -u rhino-compute /usr/bin/rhino-compute --urls http://0.0.0.0:5000 ``` -------------------------------- ### Install ghhops-server Source: https://github.com/mcneel/compute.rhino3d/blob/9.x/src/ghhops-server-py/README.md Installs the ghhops-server package using pip. ```shell pip install ghhops-server ``` -------------------------------- ### Create systemd override file Source: https://github.com/mcneel/compute.rhino3d/blob/9.x/package/SYSTEMD_SERVICE.md Create a systemd override file to customize the service. ```bash sudo systemctl edit rhino-compute ``` -------------------------------- ### Set API key Source: https://github.com/mcneel/compute.rhino3d/blob/9.x/package/SYSTEMD_SERVICE.md Set your Rhino license token in the environment file. ```bash RHINO_TOKEN=your_actual_api_key_here ``` -------------------------------- ### Run the Hops Server Source: https://github.com/mcneel/compute.rhino3d/blob/9.x/src/ghhops-server-py/README.md Starts the Flask development server to host the Hops components. ```python if __name__ == "__main__": app.run() ``` -------------------------------- ### Run the Python Script Source: https://github.com/mcneel/compute.rhino3d/blob/9.x/src/ghhops-server-py/README.md Executes the Python script to start the Hops server. ```shell python app.py ``` -------------------------------- ### Example Hops Python Component using Flask Source: https://github.com/mcneel/compute.rhino3d/blob/9.x/src/ghhops-server-py/README.md A Python example defining a Hops component that takes a curve and a number as input and returns the coordinates of a point at a given parameter on the curve. This example utilizes Flask as the HTTP server. ```python from flask import Flask import ghhops_server as hs # register hops app as middleware app = Flask(__name__) hops = hs.Hops(app) @hops.component( "/pointat", name="PointAt", description="Get point along curve", icon="examples/pointat.png", inputs=[ hs.HopsCurve("Curve", "C", "Curve to evaluate"), hs.HopsNumber("t", "t", "Parameter on Curve to evaluate"), ], outputs=[ hs.HopsPoint("P", "P", "Point on curve at t") ] ) def pointat(curve, t): return curve.PointAt(t) if __name__ == "__main__": app.run() ``` -------------------------------- ### Stop the Service Source: https://github.com/mcneel/compute.rhino3d/blob/9.x/package/SYSTEMD_SERVICE.md Stop the rhino-compute service. ```bash sudo systemctl stop rhino-compute ``` -------------------------------- ### Edit configuration file Source: https://github.com/mcneel/compute.rhino3d/blob/9.x/package/SYSTEMD_SERVICE.md Edit the environment configuration file to set the API key. ```bash sudo nano /etc/rhino-compute/environment ``` -------------------------------- ### Disable Automatic Startup Source: https://github.com/mcneel/compute.rhino3d/blob/9.x/package/SYSTEMD_SERVICE.md Disable automatic startup and stop the service. ```bash sudo systemctl disable rhino-compute sudo systemctl stop rhino-compute ``` -------------------------------- ### Restart service Source: https://github.com/mcneel/compute.rhino3d/blob/9.x/package/SYSTEMD_SERVICE.md Restart the rhino-compute service to apply environment changes. ```bash sudo systemctl restart rhino-compute ``` -------------------------------- ### Check Service Status Source: https://github.com/mcneel/compute.rhino3d/blob/9.x/package/SYSTEMD_SERVICE.md Check the current status of the rhino-compute service. ```bash sudo systemctl status rhino-compute ``` -------------------------------- ### Manual Execution Source: https://github.com/mcneel/compute.rhino3d/blob/9.x/package/SYSTEMD_SERVICE.md Manual execution of the rhino-compute service as the rhino-compute user with a specified token and URL. ```bash sudo -u rhino-compute RHINO_TOKEN=your_token \n /usr/bin/rhino-compute --urls http://0.0.0.0:5000 ``` -------------------------------- ### Create environment file for non-systemd environments Source: https://github.com/mcneel/compute.rhino3d/blob/9.x/package/SYSTEMD_SERVICE.md Create the environment file for running rhino-compute without systemd, e.g., in Docker. ```bash # Create environment file echo "RHINO_TOKEN=your_token_here" > /etc/rhino-compute/environment ``` -------------------------------- ### Uninstall rhino-compute Source: https://github.com/mcneel/compute.rhino3d/blob/9.x/package/SYSTEMD_SERVICE.md Uninstall rhino-compute by stopping the service and removing the package. ```bash # Stop and disable the service sudo systemctl disable rhino-compute sudo systemctl stop rhino-compute # Remove the package sudo dnf remove rhino-compute # RPM-based sudo apt remove rhino-compute # Debian-based ``` -------------------------------- ### Troubleshooting: Check user file access Source: https://github.com/mcneel/compute.rhino3d/blob/9.x/package/SYSTEMD_SERVICE.md Check file access permissions for the rhino-compute user in its working directory. ```bash sudo ls -la /usr/lib/rhino-compute ``` -------------------------------- ### Reload and restart service after customization Source: https://github.com/mcneel/compute.rhino3d/blob/9.x/package/SYSTEMD_SERVICE.md Reload the systemd daemon and restart the service after making custom configuration changes. ```bash sudo systemctl daemon-reload sudo systemctl restart rhino-compute ``` -------------------------------- ### Developer Notes - Running Servers Source: https://github.com/mcneel/compute.rhino3d/blob/9.x/src/ghhops-server-py/README.md Commands for running different test servers using pipenv. ```shell # Running test HTTP server pipenv run hops_http # Running test Flask server pipenv run hops_flask # Running test HTTP server with rhinoinside pipenv run hops_rhinside # Publishing package on Pypi pipenv run build ``` -------------------------------- ### Initialize Flask App and Hops Middleware Source: https://github.com/mcneel/compute.rhino3d/blob/9.x/src/ghhops-server-py/README.md Creates a Flask application instance and registers Hops as middleware. ```python # import flask, ghhops_server, and rhino3dm # rhino3dm is automatically installed with ghhops_server from flask import Flask import ghhops_server as hs import rhino3dm # register hops app as middleware app = Flask(__name__) hops = hs.Hops(app) ``` -------------------------------- ### Define a Hops Component Source: https://github.com/mcneel/compute.rhino3d/blob/9.x/src/ghhops-server-py/README.md Defines a Hops component named 'PointAt' that takes a curve and a parameter 't' as input and returns a point on the curve. ```python @hops.component( "/pointat", name="PointAt", description="Get point along curve", icon="examples/pointat.png", inputs=[ hs.HopsCurve("Curve", "C", "Curve to evaluate"), hs.HopsNumber("t", "t", "Parameter on Curve to evaluate"), ], outputs=[ hs.HopsPoint("P", "P", "Point on curve at t") ] ) def pointat(curve, t): return curve.PointAt(t) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.