# Starting as a Service

When using CommandBox on a staging or production server, you may wish to start up servers as a service when the OS comes online. The recommended approach is to use the [**CommandBox Service Manager Module**](https://www.ortussolutions.com/products/commandbox-service-manager), which is a commercial module that handles all major operating systems (Linux, Mac, Windows) automatically.

![CommandBox Service Manager](/files/-Lx3gjMH8ryxtNR4qRST)

See screencast here:

{% embed url="<https://www.ortussolutions.com/products/commandbox-service-manager>" %}

Alternatively, you can manually do so following one of these community guides.

## Windows

See screencast here: <https://www.ortussolutions.com/blog/screencast-starting-commandbox-servers-as-a-windows-service>

## MacOS

Coming soon...

## CentOS/RHEL/Ubuntu (system.d)

Create a `.service` file

```
nano /usr/lib/systemd/system/mySite.service
```

as follows:

```
[Unit]
Description=mySite Service

[Service]
ExecStart=/usr/local/bin/box server start /var/www/mySiteAPI/server.json
Type=forking

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

Start the service

```
systemctl start mySite.service
```

Give the service about a minute to load up, then check its status

```
systemctl status mySite.service
```

Once you've verified the service is running as expected, enable the service to load at boot

```
systemctl enable mySite.service
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://commandbox.ortusbooks.com/embedded-server/starting-as-a-service.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
