How to Restart or Force Rebuild Your App

App Platform is a Platform-as-a-Service (PaaS) offering that allows developers to publish code directly to DigitalOcean servers without worrying about the underlying infrastructure.


App Platform provides two options for managing your app’s container: restarting the container or forcing a rebuild. Both options are useful in different situations:

  • Restart your app’s container: Redeploys an exact copy of your app’s container without fetching updates from your source code repository. This is useful if your app is stuck in a connection loop or a deadlock. However, restarting your app does not fix issues caused by code or configuration errors.

    Restarting your app performs a rolling restart of its service and worker components; it does not restart the app’s jobs or databases. You can also restart individual services or workers.

  • Force a rebuild of your app’s container: Redeploys the app with the latest changes from your source code repository. This is useful if you have made changes to your app’s container image and want to ensure that the changes are reflected in your app.

Restart Your App Using the API or CLI

You can restart all of your app’s components by providing your app’s ID to the restart command or API endpoint. You can also restart individual components by setting the --components flag in the command, or the components field in the API, and then provide a list of component names as arguments.

How to Restart an App Using the DigitalOcean CLI
  1. Install doctl, the DigitalOcean command-line tool.

  2. Create a personal access token and save it for use with doctl.

  3. Use the token to grant doctl access to your DigitalOcean account.

              doctl auth init
              
  4. Finally, run doctl apps restart. Basic usage looks like this, but you can read the usage docs for more details:

                doctl apps restart <app id> [flags]
              

    The following example restarts an app with the ID f81d4fae-7dec-11d0-a765-00a0c91e6bf6. Additionally, the command returns the app’s ID and status:

                  doctl apps restart f81d4fae-7dec-11d0-a765-00a0c91e6bf6 --format ID,Status
                
How to Restart an App Using the DigitalOcean API
  1. Create a personal access token and save it for use with the API.

  2. Send a POST request to https://api.digitalocean.com/v2/apps/{app_id}/restart

    cURL

    Using cURL:

                    curl -X POST \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
      "https://api.digitalocean.com/v2/apps/{app_id}/restart"
                  

    Python

                    import os
    from pydo import Client
    
    client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
    
    create_resp = client.apps.restart(app_id="b6bdf840", body={"components": ["component1", "component2"]})
                  

Restart Your App Using the Control Panel

To restart your app’s container from the control panel, click on the app you want to restart and then click on the Actions button. In the Actions menu, click Restart.

The Restart or Deploy modal with the Restart tab selected.

In the Restart or Deploy modal, select whether to restart all services and workers, or restart individual components. Once you’ve selected which components to restart, click Restart. The app redeploys without importing any changes from your source code repository.

Force Rebuild Your App Using the API or CLI

You can force a rebuild of your app’s container by creating a new deployment for the app and setting the force-rebuild flag in the CLI, or the force_rebuild parameter in the API, to true. This forces the app to redeploy with the latest changes from your source code repository.

How to Force Rebuild an App Using the DigitalOcean CLI
  1. Install doctl, the DigitalOcean command-line tool.

  2. Create a personal access token and save it for use with doctl.

  3. Use the token to grant doctl access to your DigitalOcean account.

              doctl auth init
              
  4. Finally, run doctl apps create-deployment. Basic usage looks like this, but you can read the usage docs for more details:

                doctl apps create-deployment <app id> [flags]
              

    The following example creates a deployment for an app with the ID f81d4fae-7dec-11d0-a765-00a0c91e6bf6. Additionally, the command returns the app’s ID and status:

                  doctl apps create-deployment f81d4fae-7dec-11d0-a765-00a0c91e6bf6 --format ID,Status
                
How to Force Rebuild an App Using the DigitalOcean API
  1. Create a personal access token and save it for use with the API.

  2. Send a POST request to https://api.digitalocean.com/v2/apps/{app_id}/deployments

    cURL

    Using cURL:

                    curl -X POST \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
      "https://api.digitalocean.com/v2/apps/{app_id}/deployments"
                  

    Python

                    import os
    from pydo import Client
    
    client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
    
    create_resp = client.apps.create_deployment(app_id="b6bdf840", body={"force_build": True})
                  

Force a Rebuild of Your App Using the Control Panel

To force a rebuild of your app’s container from the control panel, click on the app you want to rebuild and then click on the Actions button. In the Actions menu, click Force Rebuild and Deploy.

The Restart or Deploy modal with the Force Rebuild and Deploy tab selected.

In the Restart or Deploy modal, choose whether to clear the build cache, then click Force Rebuild and Deploy. The app redeploys after fetching changes from your source code repository.