# Multiple Tunnel Startup

In projects where you need to publish multiple services, you may need to run several tunnels at once.

note

All current flags, hints, and examples can be viewed by calling help:

```shell
tuna start --help

```

## Configuration

You can describe all tunnels in the global [configuration file](https://tuna.am/en/docs/guides/config-file.md) or a local one (only for the **tunnels** section). If a local file named `.tuna.yml` is found in the current directory, it overrides the `tunnels` section from the global one. This way you can create a `.tuna.yml` in the root of the repository and it will immediately work for all developers on the team. The path to the local file can be overridden using the `--tunnels-file` flag or the `TUNA_START_TUNNELS_FILE` environment variable for the `tuna start` command.

```shell
tuna start --tunnels-file=/your/path/.tuna.yml web

```

Example configuration describing the launch of four tunnels:

```yaml
---
tunnels:
  web:
    commandLine: tuna http localhost:5173 --subdomain=web
    tags: [frontend, ui]
  api:
    commandLine: tuna http 8080 --subdomain=api
    tags: [backend, api]
  postgres:
    commandLine: tuna tcp 5432 --port=postgres
    tags: backend
  redis:
    commandLine: tuna tcp 6379 --port=redis
    tags: frontend

```

What each service consists of using the first as an example:

```yaml
web:
  commandLine: tuna http localhost:5173 --subdomain=web
  tags: [frontend, ui]

```

1. `web` - tunnel name, must be unique in the list of all tunnels
2. `commandLine` - command to create the tunnel
3. `tags` - optional field, can contain a string or a list of strings. Tags can be used to run a subset of tunnels.

## Running

The `tuna start` command is responsible for running, you can separate the launch depending on your needs.

### By service name

Run tunnel only for the api service:

```shell
tuna start api

```

Run tunnel only for api and postgres:

```shell
tuna start api postgres

```

The name can also be passed in the `TUNA_START` environment variable:

```shell
export TUNA_START="api"
tuna start

```

### By tag

Run all tunnels with the `frontend` tag:

```shell
tuna start --tags=frontend

```

Run all tunnels with the `frontend` or `backend` tag:

```shell
tuna start --tags=frontend,backend

```

Tags can also be passed in the `TUNA_START_TAGS` environment variable:

```shell
export TUNA_START_TAGS="frontend"
tuna start

```

### All at once

Run all described tunnels:

```shell
tuna start --all

```

Or with the `TUNA_START_ALL` environment variable:

```shell
export TUNA_START_ALL=true
tuna start

```
