# Restarting Connectware

This section explains how to restart Connectware. Restarting may be necessary when applying configuration changes, troubleshooting issues, or performing maintenance tasks.

{% tabs %}
{% tab title="Kubernetes" %}

### Restarting Connectware on Kubernetes

In Kubernetes environments, restarting Connectware requires scaling down all controller resources to zero before scaling them back up. The following procedure ensures a proper restart without data loss.

#### Prerequisites

* `kubectl` installed and configured to point at the target Kubernetes cluster
* [Helm version 3](https://helm.sh/docs/intro/quickstart/#install-helm) is installed on your system.
* A shell capable of storing variables (e.g. bash)

#### Procedure

1. Store the namespace that is used for Connectware in a variable:

{% code lineNumbers="true" %}

```sh
CONNECTWARE_NS=<namespace here>
```

{% endcode %}

2. Add Connectware Helm repository

If the Connectware Helm repository is already configured, you can run `helm repo update` and skip this step.

This guide assumes that the repository was added under the name "cybus". If you used a different name, make sure to adjust the commands accordingly.

{% code lineNumbers="true" %}

```sh
helm repo add cybus https://repository.cybus.io/repository/connectware-helm
```

{% endcode %}

3. Store the name and version of the Helm installation that is used for Connectware in a variable:

{% code lineNumbers="true" %}

```sh
CONNECTWARE_HELM_NAME=<helm installation name here>
CONNECTWARE_HELM_VERSION=<helm installation version here>
```

{% endcode %}

If you do not know the name or version of your Connectware installation, you can look for them by listing all Helm installations in your namespace:

{% code lineNumbers="true" %}

```sh
helm list -n $CONNECTWARE_NS
```

{% endcode %}

4. Verify your settings.

To verify that you set the correct variables, run the following command. It should display the Connectware core services:

{% code lineNumbers="true" %}

```sh
kubectl get deploy,sts -lapp.kubernetes.io/part-of=connectware -lapp.kubernetes.io/instance=$CONNECTWARE_HELM_NAME -n $CONNECTWARE_NS
```

{% endcode %}

5. Scale down all StatefulSets and Deployments in your installation:

{% code lineNumbers="true" %}

```sh
kubectl get deploy,sts -lapp.kubernetes.io/part-of=connectware -lapp.kubernetes.io/instance=$CONNECTWARE_HELM_NAME -n $CONNECTWARE_NS -o name | xargs -I % kubectl scale -n $CONNECTWARE_NS % --replicas 0
```

{% endcode %}

6. Wait until all pods have been terminated. You can monitor the termination process with the following command (press Ctrl+C once no pods are listed):

{% code lineNumbers="true" %}

```sh
while [ True ]; do clear; kubectl get pod -lapp.kubernetes.io/part-of=connectware -lapp.kubernetes.io/instance=$CONNECTWARE_HELM_NAME -n $CONNECTWARE_NS ; sleep 5; done
```

{% endcode %}

{% hint style="info" %}
If you want to stop Connectware (rather than restart it), or if you need to perform maintenance tasks while it remains stopped, you can end the procedure at this step.
{% endhint %}

7. Reapply the Helm values to start Connectware.

{% code lineNumbers="true" %}

```sh
 helm upgrade $CONNECTWARE_HELM_NAME cybus/connectware --version $CONNECTWARE_HELM_VERSION --reuse-values
```

{% endcode %}

8. Monitor the pods and confirm that all transition to the `Running` state and show as `Ready`:

{% code lineNumbers="true" %}

```sh
while [ True ]; do clear; kubectl get pod -lapp.kubernetes.io/part-of=connectware -lapp.kubernetes.io/instance=$CONNECTWARE_HELM_NAME -n $CONNECTWARE_NS ; sleep 5; done
```

{% endcode %}
{% endtab %}

{% tab title="Docker" %}

### Restarting Connectware on Docker

1. Access the system that hosts your Connectware instance via SSH.
2. Navigate to your Connectware installation directory. If you have used the default values during installation, the installation directory is `/opt/connectware`.
3. Stop the current Connectware services:

{% code lineNumbers="true" %}

```sh
docker compose down
```

{% endcode %}

4. Restart Connectware:

{% code lineNumbers="true" %}

```sh
docker compose up -d
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Verifying after Restarting

After restarting Connectware, verify that all services are running correctly:

1. Check the service status via the Admin UI. For more information, see [System Status](https://docs.cybus.io/2-0-4/documentation/system-status) and [Service Logs](https://docs.cybus.io/2-0-4/documentation/services/service-logs).
2. Verify that the connections to the data sources are reestablished.
3. Confirm that any previously configured mappings or workflows are functioning.

## Troubleshooting when Restarting Fails

If Connectware does not start properly after restart:

1. Check logs for errors.
   * For Kubernetes: `kubectl logs -n $CONNECTWARE_NS <podname>`
   * For Docker: `docker compose logs <your-connectware-container>`
2. Verify network connectivity between components.
3. Ensure that the configuration files are valid and correctly formatted.

If problems persist, contact Cybus support at <support@cybus.io>.
