Overview
Therun command is the primary way to start your Paperclip instance. It automatically handles onboarding (if needed), runs diagnostic checks, and starts the server. This is the command youβll use most often in development and production.
Syntax
Options
--config <path>
Path to config file.
Default: ~/.paperclip/instances/default/config.json
--data-dir <path>
Paperclip data directory root. Isolates state from ~/.paperclip.
--instance <id>
Local instance ID. Useful for running multiple isolated instances.
Default: default
Allowed characters: Letters, numbers, _, and -
--repair
Attempt automatic repairs during doctor checks.
Default: true
--no-repair
Disable automatic repairs during doctor checks.
What It Does
Therun command executes a three-phase startup sequence:
1. Setup Validation
Checks for existing configuration:- Creates home directory if missing
- Creates instance directory if missing
- Checks for config file
2. Auto-Onboarding
If no config is found: Interactive terminal:paperclipai onboard automatically, then continues.
Non-interactive terminal (CI/automated):
3. Health Checks
Runspaperclipai doctor with automatic repairs:
4. Server Start
If all checks pass:The server runs in the foreground. Press
Ctrl+C to stop.Examples
Start default instance
- Instance:
default - Config:
~/.paperclip/instances/default/config.json - Auto-repair: enabled
Start specific instance
~/.paperclip/instances/staging/config.json.
Custom config path
Disable auto-repair
Multiple instances
Run multiple instances simultaneously:- Unique instance ID
- Unique port (configure in
config.json) - Separate database (if using embedded-postgres)
Environment Variables
These environment variables affectrun behavior:
PAPERCLIP_INSTANCE_ID
Sets the instance ID.
PAPERCLIP_CONFIG
Explicit config file path.
PAPERCLIP_HOME
Override home directory.
PAPERCLIP_OPEN_ON_LISTEN
Auto-open browser when server starts (set internally by onboard).
PAPERCLIP_UI_DEV_MIDDLEWARE
Enable UI development middleware (auto-detected in monorepo).
Server Modes
Development Mode
If running from the monorepo workspace:- Imports
server/src/index.tsdirectly - Enables UI dev middleware
- Supports hot reloading (with tsx/nodemon)
Production Mode
If installed globally or using published package:- Imports
@paperclipai/serverpackage - Serves pre-built UI assets
- Production-optimized
Server Output
Successful Start
Request Logs
HTTP requests are logged:Database Migrations
On first start or schema changes:Stopping the Server
Graceful Shutdown
PressCtrl+C to trigger graceful shutdown:
Force Kill
If graceful shutdown hangs, pressCtrl+C again:
Troubleshooting
Port already in use
-
Check whatβs using the port:
-
Kill the conflicting process:
-
Change the port:
Database connection failed
-
Check logs:
-
Verify port is available:
-
Reset database:
-
Test connection manually:
-
Verify DATABASE_URL:
-
Update connection:
Server starts but UI not accessible
Check server config:config.json:
127.0.0.1, only accessible locally. For network access:
Module not found error
-
Reinstall dependencies:
-
Verify installation:
-
Use npx instead:
Doctor fails with blocking issues
Production Deployment
For production deployments:Using systemd
Create/etc/systemd/system/paperclip.service:
Using Docker
CreateDockerfile:
Environment Variables for Production
Set these in production:Next Steps
Verify health
Run diagnostic checks on your running instance
Update config
Modify configuration without stopping
Production setup
Deploy to production environments