Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ A configuration is a YAML file that describes what you want to run.
> you can name the configuration file `.dstack.yml` or `app.dstack.yml`. You can define
> these configurations anywhere within your project.

Configurations can be of two types: `dev-environment` and `task`.
Configurations can be of three types: `dev-environment`, `task`, and `service`.

Below is a configuration that runs a dev environment with a pre-built environment to which you can connect via VS Code Desktop.

Expand All @@ -84,6 +84,17 @@ commands:
- python app.py
```

A service configuration makes a web application available through the gateway.
Below is a configuration for a simple web server.

```yaml
type: service
gateway: my.domain.com
port: 80:8000
commands:
- python -m http.server 8000
```

## CLI

To run a configuration, use the [`dstack run`](https://dstack.ai/docs/reference/cli/run.md) command and pass the path to the
Expand Down
9 changes: 7 additions & 2 deletions cli/dstack/_internal/cli/utils/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from dstack._internal.cli.utils.watcher import LocalCopier, SSHCopier, Watcher
from dstack._internal.core.app import AppSpec
from dstack._internal.core.instance import InstanceType
from dstack._internal.core.job import Job, JobErrorCode, JobHead, JobStatus
from dstack._internal.core.job import ConfigurationType, Job, JobErrorCode, JobHead, JobStatus
from dstack._internal.core.plan import RunPlan
from dstack._internal.core.request import RequestStatus
from dstack._internal.core.run import RunHead
Expand Down Expand Up @@ -345,8 +345,13 @@ def _run_container_ssh_tunnel(hub_client: HubClient, run_name: str, ports_lock:


def _poll_logs_ws(hub_client: HubClient, job: Job, ports: Dict[int, int]):
hostname = "127.0.0.1"
if job.configuration_type == ConfigurationType.SERVICE:
hostname = job.gateway.hostname
ports = {**ports, job.gateway.service_port: job.gateway.public_port}

def on_message(ws: WebSocketApp, message):
message = fix_urls(message, job, ports, hostname="127.0.0.1")
message = fix_urls(message, job, ports, hostname=hostname)
sys.stdout.buffer.write(message)
sys.stdout.buffer.flush()

Expand Down