# How to Restart or Force Rebuild Your App App Platform is a fully managed Platform-as-a-Service (PaaS) that deploys applications from Git repositories or container images. It automatically builds, deploys, and scales components while handling all 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](https://docs.digitalocean.com/products/app-platform/how-to/manage-services/index.html.md) and [worker](https://docs.digitalocean.com/products/app-platform/how-to/manage-workers/index.html.md) components; it does not restart the app’s [jobs](https://docs.digitalocean.com/products/app-platform/how-to/manage-jobs/index.html.md) or [databases](https://docs.digitalocean.com/products/app-platform/how-to/manage-databases/index.html.md). 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`](https://docs.digitalocean.com/reference/doctl/how-to/install/index.html.md), the official DigitalOcean CLI. 2. [Create a personal access token](https://docs.digitalocean.com/reference/api/create-personal-access-token/index.html.md) and save it for use with `doctl`. 3. Use the token to grant `doctl` access to your DigitalOcean account. ```shell doctl auth init ``` 4. Finally, run `doctl apps restart`. Basic usage looks like this, but you can [read the usage docs](https://docs.digitalocean.com/reference/doctl/reference/apps/restart/index.html.md) for more details: ```shell doctl apps restart [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: ```shell 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](https://docs.digitalocean.com/reference/api/create-personal-access-token/index.html.md) and save it for use with the API. 2. Send a POST request to [`https://api.digitalocean.com/v2/apps/{app_id}/restart`](https://docs.digitalocean.com/reference/api/digitalocean//index.html.md#operation/apps_restart). ### cURL Using cURL: ```shell curl -X POST \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ "https://api.digitalocean.com/v2/apps/{app_id}/restart" ``` ### Python Using [PyDo](https://github.com/digitalocean/pydo), the official DigitalOcean API client for Python: ```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, go to the [**Apps** page](https://cloud.digitalocean.com/apps) and select the app you want to restart. Click the **Actions** menu, then select **Restart**. In the **Restart or deploy** window, choose whether to restart all services and workers or restart individual components. After selecting which components to restart, click **Restart**. The app restarts using the existing container image and does not pull in 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`](https://docs.digitalocean.com/reference/doctl/how-to/install/index.html.md), the official DigitalOcean CLI. 2. [Create a personal access token](https://docs.digitalocean.com/reference/api/create-personal-access-token/index.html.md) and save it for use with `doctl`. 3. Use the token to grant `doctl` access to your DigitalOcean account. ```shell doctl auth init ``` 4. Finally, run `doctl apps create-deployment`. Basic usage looks like this, but you can [read the usage docs](https://docs.digitalocean.com/reference/doctl/reference/apps/create-deployment/index.html.md) for more details: ```shell doctl apps create-deployment [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: ```shell 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](https://docs.digitalocean.com/reference/api/create-personal-access-token/index.html.md) and save it for use with the API. 2. Send a POST request to [`https://api.digitalocean.com/v2/apps/{app_id}/deployments`](https://docs.digitalocean.com/reference/api/digitalocean//index.html.md#operation/apps_create_deployment). ### cURL Using cURL: ```shell curl -X POST \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ "https://api.digitalocean.com/v2/apps/{app_id}/deployments" ``` ### Python Using [PyDo](https://github.com/digitalocean/pydo), the official DigitalOcean API client for Python: ```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, go to the [**Apps** page](https://cloud.digitalocean.com/apps) and select the app you want to rebuild. Click the **Actions** menu, then select **Force Rebuild and Deploy**. In the **Restart or deploy** window, choose whether to clear the build cache, then click **Force rebuild and deploy**. App Platform builds a new container image from the latest changes in your source code repository and redeploys your app.