# Under the Hood

Deploying and migrating updates across different environments, such as moving a new version from the development server to staging, is a complex process and involves many steps on both the development and the target server. With just a single click in the Devin App, these steps are all automated by the Devin APIs on the respective servers.

{% hint style="info" %}
The current version of Devin implements a default process for rolling out releases across `STAGING` and `PRODUCTION` environments. Soon, this will be extended (see [#looking-ahead-enhacing-deployment-flexibility](#looking-ahead-enhacing-deployment-flexibility "mention")).
{% endhint %}

## Default Deployment Pipeline

The Default Deployment Pipeline listens for new [Releases](https://docs.devin.fm/guides/releases) to an [Environment](https://docs.devin.fm/guides/deployment-environments)'s Release [Branch](https://docs.devin.fm/guides/branches) that has a different [version number](https://docs.devin.fm/guides/versions/save-a-version#version-numbers) than the [Deployment's](https://docs.devin.fm/guides/deployment-environments). This means that if your production environment uses your main branch as release branch and a higher or lower [Version](https://docs.devin.fm/guides/versions) is released to `main`, this pipeline lets you roll out the release using a standardised and automated deployment and data migration process.&#x20;

For a guide on how to trigger this pipeline for a deployment, see [deploy-a-release](https://docs.devin.fm/guides/releases/deploy-a-release "mention").

<figure><img src="https://3674518083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4WyrF9yRB5bw5h1SRZke%2Fuploads%2FNC5jBM6nu3tvC42hNRv4%2FDefaultDeploymentProcess.jpeg?alt=media&#x26;token=bb73a7c7-cab7-408e-a843-722f8d898058" alt=""><figcaption><p>Devin's Default Deployment Process</p></figcaption></figure>

### What happens on the Development Server

1. **Cloning the respective Branch File**: Clones the latest Version that was released to the respective release branch.
2. **Transfer**: The cloned file is securely transferred to the target server.

### What happens on the Target Server

1. **Close Live File**: Temporarily closes the original live file (if no users are connected to it). (we are currently investigating approaches for supporting zero-downtime data migration processes)
2. **Data Migration**: Utilizes the FileMaker Data Migration CLI Tool to migrate data from the original file to the new version.
3. **File Replacement**: Moves and opens the new file, replacing the old version.

## Safety and Recovery Mechanisms

Devin Server APIs incorporate robust safety features that handle communication and process execution between servers, designed to handle the complexities and potential risks involved in updating and migrating data across environments. These mechanisms ensure that the system remains stable and secure throughout the deployment process, safeguarding against disruptions that could impact business operations.&#x20;

### Error Handling and Rollback Capabilities

#### Proactive Monitoring

Devin continuously monitors servers and processes for any signs of issues. This includes checking that FileMaker Server runs as expected, that servers has enough resources available to perform actions and that update processes are not initiated if there are users connected to the respective file(s).&#x20;

#### Automatic Rollbacks

In case of an error during the deployment or migration phase, Devin is engineered to automatically revert to the previous state of the application. This rollback is triggered if specific error conditions are met, ensuring that the live environment remains unaffected by the failed update attempt.

### Security and Integrity Checks

#### Access Controls and Authentication

All communication between Devin Server APIs, including server status checks, file transfers and data migration logs, utilizes the SSL certificate installed on FileMaker Server. This ensures that every interaction is securely encrypted and authenticated, safeguarding against unauthorized access and protecting data integrity. Read more about [network-considerations](https://docs.devin.fm/setup-and-maintenance/prerequisites/network-considerations "mention") in the Setup & Maintenance section. &#x20;

#### Data Verification (not yet implemented)

{% hint style="warning" %}
Devin does not verify the integrity of the data being migrated during the data migration process. If the FileMaker Data Migration Tool completes sucesfully, Devin will interpret the migration step as succeeded and continue. The data migration logs can be viewed in the Devin App's Project Workspace -> Migrations -> Details.
{% endhint %}

## Execution Safety

### Process Queuing and Isolation

To safeguard live environments from disruptions, Devin Server APIs utilize a sophisticated subprocess and queuing system for all its processes. This queuing system manages all operations as isolated tasks and prevents Devin from starting more concurrent processes than it can handle or is configured for (see [#hardware-and-concurrency](https://docs.devin.fm/setup-and-maintenance/prerequisites/system-requirements#hardware-and-concurrency "mention")).

This means that processes may enter a queue and wait to be triggered. For example, if multiple developers simultaneously initiate operations on a Development server, some processes might experience a delay before starting.&#x20;

{% hint style="info" %}
Devin Server runs as a background system service on your server. On Windows it is installed and managed as a native `Windows Service`, and on Unix (Linux/macOS) it is configured as a `systemd` service, managed with `systemctl`.
{% endhint %}

## Looking Ahead: Enhacing Deployment Flexibility

Devin currently adheres to a structured process for deployment updates to maintain system stability. However, we are excited about the upcoming releases of features that we call **Cycles** and custom **Pipelines**. These will not only offer more advanced and customizable deployment workflows but also the ability to integrate automated [regression-testing](https://docs.devin.fm/features/regression-testing "mention") within these workflows. Stay tuned 🚀
