Bare metal
Hyperterse is a standalone binary, so you can run it directly on servers without containers. It requires no external dependencies, and is as simple as dropping the binary on the server and running it.
Quick start
Section titled “Quick start”-
Export bundle
Terminal window hyperterse export -f my-query-gateway.terse -o dist -
Transfer to server
Terminal window scp -r dist/my-query-gateway user@server:/opt/my-query-gateway -
Run on server
Terminal window ssh user@servercd /opt/my-query-gatewayexport DATABASE_URL="postgresql://user:pass@localhost:5432/app"./my-query-gateway
Systemd service
Section titled “Systemd service”Since Hyperterse is a standalone binary, you can run it as a system service.
-
Create the systemd service file
/etc/systemd/system/my-query-gateway.service [Unit]Description=My Query GatewayAfter=network.target postgresql.serviceWants=postgresql.service[Service]Type=simpleUser=hyperterseGroup=hyperterseWorkingDirectory=/opt/my-query-gatewayEnvironmentFile=/opt/my-query-gateway/.envExecStart=/opt/my-query-gateway/my-query-gatewayRestart=alwaysRestartSec=5# Security hardeningNoNewPrivileges=trueProtectSystem=strictProtectHome=truePrivateTmp=trueReadOnlyPaths=/[Install]WantedBy=multi-user.target -
Create the environment file
/opt/my-query-gateway/.env DATABASE_URL=postgresql://user:pass@localhost:5432/appREDIS_URL=redis://localhost:6379/0 -
Enable and start the service
Terminal window # Create usersudo useradd -r -s /bin/false hyperterse# Set permissionssudo chown -R hyperterse:hyperterse /opt/my-query-gateway# Enable and startsudo systemctl enable my-query-gatewaysudo systemctl start my-query-gateway# Check statussudo systemctl status my-query-gateway
Process Manager (PM2)
Section titled “Process Manager (PM2)”You can use a process manager like PM2 to start and manage the service.
-
Install PM2
Terminal window npm install -g pm2 -
Start the service
Terminal window pm2 start /opt/my-query-gateway/my-query-gateway -
Save configuration and enable startup
Terminal window pm2 savepm2 startup
Nginx reverse proxy
Section titled “Nginx reverse proxy”You can also use Nginx to reverse proxy the service.
-
Create the Nginx configuration file
/etc/nginx/sites-available/my-query-gateway upstream hyperterse {server 127.0.0.1:8080;keepalive 32;}server {listen 80;server_name api.example.com;return 301 https://$server_name$request_uri;}server {listen 443 ssl http2;server_name api.example.com;ssl_certificate /etc/letsencrypt/live/api.example.com/fullchain.pem;ssl_certificate_key /etc/letsencrypt/live/api.example.com/privkey.pem;location / {proxy_pass http://hyperterse;proxy_http_version 1.1;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;proxy_set_header Connection "";}} -
Enable and start the service
Terminal window sudo ln -s /etc/nginx/sites-available/my-query-gateway /etc/nginx/sites-enabled/sudo nginx -t && sudo systemctl reload nginx -
SSL with Let’s Encrypt
Terminal window sudo apt install certbot python3-certbot-nginxsudo certbot --nginx -d api.example.com