# Service command - Start Aitm as service

You can start Aitm as a service. It will start:

* a web interface
* and a [proxy](../reference/proxy "../reference/proxy")

## How to

### Start it as background process

Execute the *service* command

```bash
aitm service start
# then to stop it
aitm service stop
```

### Start it as foreground process to be controlled by a supervisor

Execute the *service* command with the foreground option

```bash
aitm service start -f
# or
aitm service start --foreground
# then
# to stop it press Ctrl+C
```

You can then use them in your supervisor (SystemD, Docker, ...).

For instance with SystemD, you need to create the below file in */etc/systemd/system/aitm.service*:

```ini
[Unit]
Description=aitm service
After=network-online.target
Wants=network-online.target

[Service]
ExecStart=/usr/local/bin/aitm service start --foreground
Restart=on-failure

[Install]
WantedBy=multi-user.target
```

Then, you can control the service:

```bash
# enable
sudo systemctl enable --now aitm
# start
sudo systemctl start
# stop
sudo systemctl start
```

### How to use the proxy service in your cli or code

See [How to use the service proxy](../reference/proxy#how-to-use-the-service-proxy "../reference/proxy#how-to-use-the-service-proxy")

### Start 2 services on one machine

You can start 2 services instance by setting 2 different [runtime directories](#runtime-directory "#runtime-directory")

## Configuration

### Runtime Directory

By default, the service uses the *service* [runtime directory](../reference/runtime-directory "../reference/runtime-directory")

### Proxy Port

By default, the [proxy port](../reference/proxy#port "../reference/proxy#port")

## Note

### No sandboxing

In this mode, there is no [sandboxing](../reference/sandboxing "../reference/sandboxing") as aitm does not start the [cli/agent](../reference/cli "../reference/cli")
