Deployment Model
π¦ Understanding WEMAZU's deployment architecture, lifecycle, and rollback mechanisms.
This document explains how WEMAZU handles deployments, from the moment you trigger a deployment to its completion or failure.
Table of Contents
- Core Principles
- Branch-to-Domain Mapping
- Deployment Lifecycle
- Deployment Phases
- Deployment Types
- Rollbacks
- What Rollbacks Do NOT Do
Core Principles
WEMAZU's deployment model is built on three core principles:
1. Predictability
Every deployment follows the same predictable flow:
- β Same steps every time
- β Clear status transitions
- β Comprehensive logging at each step
- β No "magic" or hidden operations
2. Safety
Deployments are designed to be safe:
- β No automatic rollbacks (you control when to rollback)
- β Previous deployments remain intact
- β Failed deployments don't affect live sites
- β Full audit trail of all actions
3. Transparency
You always know what's happening:
- β Real-time status updates
- β Detailed logs for every step
- β Clear error messages when things fail
- β Complete deployment history
Branch-to-Domain Mapping
How Branches Map to Domains
WEMAZU does not create Git branches. We read branches from your GitHub repository. You map a branch to a domain, server, and deploy path when you add or edit a domain. You can add as many branchβdomain/server mappings as you want.
Example:
Domain: staging.example.com
βββ Branch: develop β Server A β /var/www/staging
Domain: example.com
βββ Branch: main β Server B β /var/www/production
Domain Branches
Each domain can have multiple branch configurations (each with its own server and deploy path):
Example Configuration:
Project: My Web App
Domain: example.com
βββ Branch: main β Server A β /var/www/production (auto-deploy: ON)
βββ Branch: develop β Server A β /var/www/staging (auto-deploy: ON)
βββ Branch: feature/test β Server A β /var/www/test (auto-deploy: OFF)
Key Points:
- β Branches are read from GitHub; you select which branch to deploy for each row
- β Multiple branches can deploy to the same domain (with different paths)
- β Each branch row has its own server and deploy path
- β Auto-deploy can be enabled/disabled per branch
- β Branch names are case-insensitive (normalized)
Branch Path Resolution
When deploying, WEMAZU uses the deploy path for the branch configuration (domain_branches row) you are deploying. If that row has a deploy_path set, that is used; otherwise the domainβs default deploy_path is used. If no path is found, deployment fails with a clear error message.
Deployment Lifecycle
High-Level Flow
graph TD
A[Trigger Deployment] --> B[Create Deployment Record]
B --> C[Status: queued]
C --> D[Status: building]
D --> E{Deployment Type}
E -->|FTP/SFTP| F[Download Archive]
E -->|SSH/VPS| G[Git Operations]
F --> H[Extract & Upload]
G --> I[Git Pull]
H --> J{Success?}
I --> J
J -->|Yes| K[Status: success]
J -->|No| L[Status: failed]
K --> M[Update Domain Status]
L --> N[Log Error]
Status Transitions
Deployments follow a strict status flow:
queued β building β success
β
failed
Status Meanings:
queued: Deployment is created and waiting to startbuilding: Deployment is actively executingsuccess: Deployment completed successfullyfailed: Deployment encountered an error
Important: Once a deployment reaches success or failed, it cannot transition to another status. To redeploy, a new deployment record is created.
Deployment Phases
Phase 1: Queued
What Happens:
- Deployment record is created in database
- Status is set to
queued - Deployment is ready to execute
Deployment Record:
- Deployment is created with a unique ID
- Status is set to
queued - All deployment metadata is stored
Logs:
- β
Deployment creation logged to
logstable - β
File log entry in
deployment-debug.log
Duration: < 1 second (immediate)
Phase 2: Building
What Happens:
- Status updates to
building build_started_attimestamp is set- Domain status updates to
deploying(if domain exists) - Actual deployment execution begins
Status Update:
- Status changes to
building - Build start timestamp is recorded
Logs:
- β Status change logged
- β Build start logged with server and path information
Duration: Varies based on deployment type and repository size
Phase 3: Execution
This is where the actual deployment happens. The process differs based on deployment type:
FTP/SFTP Deployment Execution
Steps:
Fetch Repository Archive
- Calls GitHub API:
GET /repos/{owner}/{repo}/zipball/{branch} - Downloads ZIP archive to temporary location
- Handles HTTP errors (404, 403, 500) with retries
- Calls GitHub API:
Extract Archive
- Extracts ZIP to temporary directory
- Handles extraction errors
Upload Files
- FTP: Uses
FtpAdapterto upload files via FTP - SFTP: Uses
SftpAdapterto upload files via SFTP - Uploads all files from extracted archive
- Preserves directory structure
- FTP: Uses
Cleanup
- Removes temporary files
- Closes FTP/SFTP connections
Logs:
- β Archive download progress
- β Extraction status
- β Upload progress (file count, errors)
- β Connection status
Common Errors:
- β GitHub API rate limit exceeded
- β Invalid repository or branch
- β FTP/SFTP connection failure
- β Permission denied on server
- β Disk space full on server
SSH/VPS Deployment Execution
Steps:
Verify Path Exists
- Checks if deploy path exists on server
- Verifies path is accessible
Git Operations
cd /var/www/production git fetch origin git checkout main git pull origin mainVerify Success
- Checks git command exit codes
- Verifies files were updated
Prerequisites:
- β Repository must already exist on server (WEMAZU does not clone)
- β Git must be installed on server
- β SSH user must have write permissions
- β Server must have network access to GitHub
Logs:
- β SSH connection status
- β Git command output (stdout/stderr)
- β File change detection
- β Error messages from git commands
Common Errors:
- β Repository not found on server
- β Git not installed
- β Permission denied
- β Branch does not exist
- β Merge conflicts (git pull fails)
Phase 4: Success
What Happens:
- Status updates to
success build_completed_attimestamp is set- Domain status updates to
active(if domain exists) - Deployment output is saved (for SSH deployments)
Status Update:
- Status changes to
success - Build completion timestamp is recorded
- Deployment output is saved (for SSH deployments)
Logs:
- β Success logged with deployment ID
- β Output saved (for SSH deployments)
- β Domain status update logged
Duration: < 1 second (status update only)
Phase 5: Failed
What Happens:
- Status updates to
failed build_completed_attimestamp is set- Error message is saved
- Domain status updates to
error(if domain exists) - Full error context is logged
Status Update:
- Status changes to
failed - Build completion timestamp is recorded
- Error message and output are saved
Logs:
- β Error logged with full context
- β Stack trace saved (truncated to 1000 chars)
- β Suggested action included
- β Domain status update logged
Error Information:
- Error message
- Stack trace (if available)
- Deployment context (project, domain, branch, commit)
- Suggested action (e.g., "Check server connection")
Deployment Timeline
Visual Timeline
Time Status Action
βββββββββββββββββββββββββββββββββββββββββ
00:00 queued Deployment created
00:01 building Status updated, execution starts
00:02 building [FTP] Downloading archive...
00:05 building [FTP] Extracting archive...
00:06 building [FTP] Uploading files...
00:30 building [FTP] Upload complete
00:31 success Deployment completed
Typical Durations
| Deployment Type | Typical Duration | Factors |
|---|---|---|
| FTP (small repo) | 10-30 seconds | File count, connection speed |
| FTP (large repo) | 1-5 minutes | Repository size, upload speed |
| SFTP (small repo) | 15-45 seconds | Encryption overhead, file count |
| SFTP (large repo) | 2-8 minutes | Repository size, encryption overhead |
| SSH/VPS | 5-15 seconds | Git operations, network speed |
Note: Durations vary significantly based on:
- Repository size
- Network speed
- Server performance
- Number of files
Deployment Types
FTP Deployment
Use Case: Traditional shared hosting with FTP access
How It Works:
- Downloads repository ZIP archive from GitHub
- Extracts archive to temporary directory
- Uploads all files via FTP to deploy path
- Preserves directory structure
Requirements:
- β FTP server accessible
- β Valid FTP credentials
- β Write permissions on deploy path
- β
GitHub token with
reposcope (for archive download)
Limitations:
- β No Git history on server
- β Full file upload every time (no incremental updates)
- β Slower for large repositories
SFTP Deployment
Use Case: Secure file transfer to servers without Git
How It Works:
- Downloads repository ZIP archive from GitHub
- Extracts archive to temporary directory
- Uploads all files via SFTP to deploy path
- Preserves directory structure
Requirements:
- β SFTP server accessible
- β Valid SFTP credentials (or SSH key)
- β Write permissions on deploy path
- β
GitHub token with
reposcope
Advantages over FTP:
- β Encrypted transfer
- β More secure authentication
- β Better error handling
Limitations:
- β No Git history on server
- β Full file upload every time
- β Slower than SSH/VPS deployments
SSH/VPS Deployment
Use Case: Virtual Private Servers with Git installed
How It Works:
- Connects to server via SSH
- Navigates to deploy path (must be existing Git repository)
- Runs:
git fetch origin - Runs:
git checkout {branch} - Runs:
git pull origin {branch}
Requirements:
- β SSH access to server
- β Git installed on server
- β Repository already cloned on server
- β Write permissions on deploy path
- β Network access to GitHub from server
Advantages:
- β Fast (only downloads changes)
- β Preserves Git history
- β Can use Git hooks (pre-deploy, post-deploy)
- β Can handle merge conflicts (manual resolution)
Limitations:
- β Requires Git on server
- β Repository must be pre-cloned
- β More complex setup
Rollbacks
What is a Rollback?
A rollback in WEMAZU means: Deploying a previous successful commit to the same domain.
Important: Rollbacks are not automatic. You must manually trigger them.
How Rollbacks Work
Step 1: Select Previous Deployment
- Go to your Project β Deployments tab
- Find a previous successful deployment
- Click "Rollback" button
Step 2: Rollback Process
WEMAZU:
- β Identifies the target deployment's commit SHA
- β Creates a new deployment record (not modifying the old one)
- β Deploys that commit to the same domain
- β Follows the same deployment lifecycle as a normal deployment
Rollback Process:
- WEMAZU finds the previous successful deployment for the domain
- Creates a new deployment record with that commit SHA
- Executes the deployment using the same process as a normal deployment
Step 3: Execution
The rollback deployment executes exactly like a normal deployment:
- β Same deployment type (FTP/SFTP/SSH)
- β Same deploy path
- β Same server
- β Same lifecycle (queued β building β success/failed)
Rollback Limitations
What Rollbacks CANNOT Do:
- β Restore Database Changes: If your code changes included database migrations, rolling back code does not roll back the database
- β Restore File Deletions: If files were deleted in a later deployment, rolling back may not restore them (depends on deployment type)
- β Undo Configuration Changes: Server configuration changes are not affected
- β Restore External Dependencies: Changes to external services (APIs, CDNs) are not rolled back
What Rollbacks CAN Do:
- β Restore Code: Previous version of your code is deployed
- β Restore File Structure: File structure from previous deployment is restored (for FTP/SFTP)
- β
Git Checkout: For SSH/VPS, performs
git checkout {previous_commit}
Rollback Best Practices
- Test First: Test rollbacks on a non-production domain or path before using on live
- Document Dependencies: Keep track of database migrations and external changes
- Monitor After Rollback: Check logs and application behavior after rollback
- Plan Ahead: Know which deployments are "safe" to roll back to
Rollback Example
Scenario:
Deployment #10: Commit abc123 (success) β Current live
Deployment #11: Commit def456 (success) β New deployment
Deployment #12: Commit ghi789 (failed) β Broken deployment
Rollback Process:
- Click "Rollback" on Deployment #10
- WEMAZU creates Deployment #13 with commit
abc123 - Deployment #13 executes and succeeds
- Your site is now back to the state of Deployment #10
Result:
- β
Code is restored to commit
abc123 - β Database changes from Deployment #11 are NOT rolled back
- β External API changes are NOT rolled back
What Rollbacks Do NOT Do
1. Database Rollbacks
Problem: If your deployment included database migrations, rolling back code does not roll back the database.
Example:
Deployment #10: Added users table (migration)
Deployment #11: Modified users table structure
Rollback to #10: Code is rolled back, but database still has new structure
Solution: Maintain separate database migration rollback scripts if needed.
2. File Deletion Recovery
Problem: If a later deployment deleted files, rolling back may not restore them.
FTP/SFTP:
- β Files are uploaded from archive, so deleted files are restored
- β οΈ But if files were added after the rollback target, they remain
SSH/VPS:
- β
git checkoutrestores files from that commit - β οΈ But uncommitted files on server are not affected
3. Configuration Changes
Problem: Server configuration changes (.htaccess, nginx.conf, etc.) are not rolled back if they were made outside WEMAZU.
Example:
Deployment #10: Code only
Manual change: Modified .htaccess on server
Deployment #11: Code update
Rollback to #10: Code is rolled back, but .htaccess changes remain
4. External Dependencies
Problem: Changes to external services are not rolled back.
Examples:
- API endpoints changed
- CDN configuration updated
- Third-party service integrations modified
5. Environment Variables
Problem: Environment variable changes on the server are not rolled back.
Example:
Deployment #10: Uses API_KEY=v1
Manual change: API_KEY=v2 set on server
Deployment #11: Code update
Rollback to #10: Code is rolled back, but API_KEY=v2 remains
Deployment Records
What Gets Stored
Every deployment creates a deployment record with the following information:
Deployment Information:
- Unique deployment ID
- Associated project
- Target domain and branch (the branchβdomain/server mapping you configured)
- Git branch deployed
- Commit SHA deployed
- Current status (queued/building/success/failed)
- Build start and completion timestamps
- Deployment output (for SSH deployments)
- Error message (if failed)
- User who triggered deployment
- Creation and update timestamps
Deployment History
You can view deployment history in:
- Project Detail Page β Deployments tab
- Dashboard β Deployments list
Filters:
- Filter by project
- Filter by domain
- Filter by status
- Filter by date range
Troubleshooting
Deployment Stuck in "Queued"
Problem: Deployment never transitions to "building".
Possible Causes:
- Deployment service is not running
- Database connection issue
- Exception thrown before status update
Solution:
- Check
deployment-debug.logfor errors - Verify deployment service is running
- Check database connectivity
Deployment Stuck in "Building"
Problem: Deployment never completes.
Possible Causes:
- Long-running operation (large repository)
- Network timeout
- Server connection lost
- Process killed
Solution:
- Check
deployment-debug.logfor last activity - Verify server is accessible
- Check network connectivity
- Consider increasing timeout values
"Deployment failed" with No Error Message
Problem: Deployment shows "failed" but no error details.
Solution:
- Check Dashboard β Logs for detailed error
- Check
deployment-debug.logfile - Verify server logs for connection issues
FTP/SFTP Upload Fails
Problem: Files fail to upload.
Check:
- Permissions: Ensure FTP/SFTP user has write permissions
- Disk Space: Verify server has enough disk space
- Path: Ensure deploy path exists and is correct
- Connection: Test FTP/SFTP connection manually
SSH Git Pull Fails
Problem: git pull fails during deployment.
Check:
- Repository: Ensure repository exists on server
- Permissions: Ensure SSH user can write to repository
- Git: Verify Git is installed on server
- Network: Ensure server can access GitHub
- Merge Conflicts: Check for uncommitted changes or merge conflicts
Next Steps:
- π Environments & Domains - Configure your deployment targets
- π Logs & Monitoring - Monitor your deployments
- π Security & Responsibility Boundaries - Understand security practices