# 라이선스 서버에 대한 서비스 설정

> Set up a service to automatically start the Unity Licensing Server on startup.

이 작업은 [Unity Licensing Server 설정](./server-setup.md)을 위한 포괄적인 프로세스의 일부입니다.

[라이선스 서버를 테스트](./server-setup-test.md)한 후, 시작 시 라이선스 서버를 자동으로 시작하도록 서비스를 설정할 수 있습니다. 프로세스를 수동으로 일시 중지, 중지하고 다시 시작할 수도 있습니다.

선택 사항이지만 라이선스 서버 프로세스를 실행하도록 서비스를 설정하는 것이 권장되는 성공 사례입니다.

이 서비스를 설정한 후에는 라이선스 서버 구성을 백업해야 합니다. [백업 및 복원](./server-setup-bkup.md)을 참조하십시오.

## 서비스 생성

> **Important:**
>
> [서버를 설정](./server-setup-cfg.md)하고 [라이선스 아카이브 파일을 임포트](./server-setup-lic.md)하는 데 사용한 것과 동일한 서비스 계정을 사용하십시오.

라이선스 서버를 중지하고 시작하기 위한 서비스를 생성하려면 운영체제에 따른 지침을 따릅니다.

* [Linux](#creating-a-service-on-linux)
* [Windows](#creating-a-service-on-windows)

### Linux에서 서비스 생성##creating-a-service-on-linux

`create-service` 커맨드는 다음을 수행합니다.

* `unity.licensing.server.service`라는 `systemd` 서비스 단위를 생성합니다.
* 현재 루트가 아닌 사용자 계정으로 실행되도록 서비스를 구성합니다.
* 시작 시 자동으로 시작되도록 서비스를 구성합니다.
* 서비스를 시작합니다.

> **Note:**
>
> 선택한 포트가 이미 다른 애플리케이션에서 사용되고 있고 서버가 실행되지 않는 경우 처음부터 `setup` 커맨드를 다시 실행하고 다른 포트를 선택하십시오.
>
> `create-service` 커맨드에는 관리자 권한이 필요합니다. 터미널에 `sudo`를 입력하여 높은 권한으로 이 커맨드를 실행하십시오.

1. 서비스를 생성하려면 다음 커맨드를 실행합니다.

```bash
sudo ./Unity.Licensing.Server create-service
```

다음 디스플레이와 유사한 출력이 표시됩니다.

```bash
- - - -
Welcome to Unity Licensing Server create service command line interface.
This command line interface will help you create Unity.Licensing.Server service.
- - - -

Creating service for user 'adminuser' ...
Enabling service to start automatically after (re)boot ... Done
Starting service ... Done
unity.licensing.server.service has been successfully created and running.
```

2. 서비스 상태를 확인하려면 다음 커맨드를 실행합니다.

```bash
sudo systemctl status unity.licensing.server.service
```

터미널 출력에서 `Active: active running`을 찾습니다.


**Frame:**
![](/api/media?file=/licensing-server/media/images/create-service-linux-status.png)

### Windows에서 서비스 생성##creating-a-service-on-windows

`create-service` 커맨드에는 관리자 권한이 필요합니다. 반드시 높은 권한으로 PowerShell 창을 시작하십시오. 관리자 계정과 공백이 아닌 비밀번호를 사용해야 합니다.

1. 사용자에게 서비스로 로그온할 수 있는 권한을 부여합니다. 이 권한을 할당하려면 다음을 수행합니다.

   * Windows 검색 창에서 `Local Security Policy`를 검색하고 정책 편집기를 엽니다.
   * 왼쪽 메뉴에서 **보안 설정** > **로컬 정책** > **사용자 권한 할당**으로 이동하고 **서비스로 로그온**을 선택합니다.
   * **사용자 또는 그룹 추가**를 클릭합니다.
   * 텍스트 상자에 사용자 이름을 입력하고 **이름 확인** > **확인**을 클릭합니다.
   * **확인**을 클릭합니다.

2. 서비스를 생성하려면 높은 권한으로 PowerShell 창을 시작하고 다음 커맨드를 실행합니다.

   ```bash
   .\Unity.Licensing.Server.exe create-service
   ```

3. 서비스를 생성하는 데 사용한 관리자 계정의 비밀번호를 입력합니다. `create-service` 커맨드는 다음과 유사한 출력을 반환합니다.

   ```bash
   - - - -
   Welcome to Unity Licensing Server create service command line interface.
   This command line interface will help you create Unity.Licensing.Server    service.
   - - - -

   Enter password for user 'HQ\adminuser':  ***********
   Windows service installation successful!
   Service Name = Unity.Licensing.Server
   Description = The Unity Licensing Server is a secure web server to host and
   manage Unity licenses on your local network
   ```

4. 서비스 상태를 확인하려면 다음 커맨드를 실행합니다.

   ```bash
   sc.exe query Unity.Licensing.Server
   ```

   PowerShell 창의 출력에서 `STATE` 정보를 찾습니다.

   ```bash
   SERVICE_NAME: Unity.Licensing.Server
           TYPE               : 10  WIN32_OWN_PROCESS
           STATE              : 4  RUNNING
                                   (STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN)
           WIN32_EXIT_CODE    : 0  (0x0)
           SERVICE_EXIT_CODE  : 0  (0x0)
           CHECKPOINT         : 0x0
           WAIT_HINT          : 0x0
   ```

   `STATE` 값에 `4 RUNNING` 이외의 항목이 표시되면 Windows 서비스를 열고 이를 관리할    `Unity.Licensing.Server` 서비스를 찾습니다.

## 서비스 다시 시작##restarting-the-service

표준 운영체제 커맨드를 사용하여 라이선스 서버 서비스를 중지하거나 다시 시작할 수 있습니다.

> **Note:**
>
> 선택한 포트가 이미 다른 애플리케이션에서 사용되고 있고 서버가 실행되지 않는 경우 처음부터 `setup` 커맨드를 다시 실행하고 다른 포트를 선택하십시오. 이 작업은 라이선스 서버의 유효성을 차단합니다. 일반적으로 트래픽이 낮을 때나 조직의 유지 관리 기간 동안 이 작업을 수행해야 합니다.

운영체제에 따라 다음 지침을 따릅니다.

* [Linux](#restarting-the-service-on-linux)
* [Windows](#restarting-the-service-on-windows)

### Linux에서 서비스 다시 시작##restarting-the-service-on-linux

1. 라이선스 서버 서비스를 시작하거나 다시 시작하려면 다음 커맨드를 실행합니다.

```bash
sudo systemctl restart unity.licensing.server.service
```

2. 서비스가 실행 중인지 확인하려면 다음 커맨드를 실행합니다.

```bash
sudo systemctl status unity.licensing.server.service | grep Active
```

서비스가 실행 중인 경우 위 커맨드의 출력결과는 아래 예시와 같이 확인할 수 있습니다.

```bash
Active: active (running) since Fri 2020-02-14 16:44:59 EST; 2s ago
```

### Windows에서 서비스 다시 시작##restarting-the-service-on-windows

1. 라이선스 서버 서비스를 시작하거나 다시 시작하려면 다음 커맨드를 실행합니다.

```bash
sc.exe query Unity.Licensing.Server | findstr /i State
```

2. 출력에 `STATE: 4 RUNNING`이 표시되면 다음 커맨드를 실행하여 서비스를 중지합니다.

```bash
sc.exe stop Unity.Licensing.Server
```

3. 출력에 `STATE: 1 STOPPED`가 표시되면 다음 커맨드를 실행하여 서비스를 다시 시작합니다.

```bash
sc.exe start Unity.Licensing.Server
```

4. 서비스 상태를 다시 확인하려면 다음 커맨드를 실행합니다.

```bash
sc.exe query Unity.Licensing.Server | findstr /i State
```

출력에 `STATE: 4 RUNNING`이 표시되면 서비스가 성공적으로 다시 시작된 것입니다.

## 서비스 삭제##deleting-the-service

라이선스 서버 서비스를 삭제해야 하는 경우 운영체제에 따른 지침을 따릅니다.

* [Linux](#deleting-the-service-on-linux)
* [Windows](#deleting-the-service-on-windows)

### Linux에서 서비스 삭제##deleting-the-service-on-linux

라이선스 서버 서비스를 삭제하려면 다음을 수행합니다.

1. 서비스를 중지하려면 다음 커맨드를 실행합니다.

```bash
sudo systemctl stop unity.licensing.server.service
```

2. 서비스를 비활성화하고 다음 시작 시 서비스가 실행되지 않도록 하려면 다음 커맨드를 실행합니다.

```bash
sudo systemctl disable unity.licensing.server.service
```

3. 서비스를 비활성화했는지 확인하려면 다음 커맨드를 실행합니다.

```bash
sudo systemctl status unity.licensing.server.service | grep Loaded
```

서비스가 비활성화된 경우 위 커맨드의 출력결과는 아래 예시와 같이 확인할 수 있습니다.

```bash
Loaded: loaded (/etc/systemd/system/unity.licensing.server.service; **disabled**; vendor preset: enabled)
```

4. 서비스 단위를 삭제하려면 다음 커맨드를 실행합니다.

```bash
sudo rm -rf /etc/systemd/system/unity.licensing.server.service
```

5. 변경 사항을 반영하려면 다음 커맨드를 실행합니다.

```bash
sudo systemctl daemon-reload
```

### Windows에서 서비스 삭제##deleting-the-service-on-windows

라이선스 서버 서비스를 삭제하려면 다음을 수행합니다.

1. 서비스를 중지하려면 다음 커맨드를 실행합니다.

```bash
sc.exe stop Unity.Licensing.Server
```

2. 서버 상태를 확인하려면 다음 커맨드를 실행합니다.

```bash
sc.exe query Unity.Licensing.Server | findstr /i State
```

3. 출력에 `STATE: 1 STOPPED`가 표시되면 다음 커맨드를 실행하여 서비스를 삭제합니다.

```bash
sc.exe delete Unity.Licensing.Server
```

서비스를 삭제하면 다음 메시지가 표시됩니다.

```bash
[SC] DeleteService SUCCESS
```

## 다음 단계

라이선스 서버 설정을 계속하려면 [백업 및 복원](./server-setup-bkup.md)을 진행합니다.
