返回

如何将 JetBrains Youtrack ZIP 版作为 Windows 服务运行?

windows

## 将 JetBrains Youtrack ZIP 版本作为 Windows 服务运行

在 Youtrack 2023.2 及更高版本中,不再提供 MSI 安装程序。虽然我们可以下载 ZIP 文件,但我们希望像旧版本一样以服务的方式运行 Youtrack。本文将介绍如何使用 PowerShell 在不使用第三方程序的情况下创建 Windows 服务。

## 创建服务脚本

第一步是创建一个 PowerShell 脚本,内容如下:

New-Service -Name YoutrackService -DisplayName "JetBrains Youtrack Service" -Description "Runs JetBrains Youtrack using the ZIP distribution."

$executable = "C:\path\to\youtrack\bin\youtrack-server.sh"
$args = "-Djava.awt.headless=true -jar youtrack-server.jar"

Set-Service -InputObject $service -Properties @{
    PathName            = "$executable $args"
    StartupType         = "Automatic"
    DependentServices   = @()
    InstallState        = "Installed"
    Status              = "Stopped"
}

Start-Service -Name YoutrackService

请将 $executable 变量替换为 youtrack-server.sh 文件的实际路径。

## 导入并启用脚本

接下来,使用提升的 PowerShell 提示符导入脚本:

Import-Module C:\path\to\youtrack-service.ps1

然后,启用服务:

Enable-Service YoutrackService

## 启动服务

最后,运行以下命令启动服务:

Start-Service YoutrackService

使用 Get-Service YoutrackService | Format-List Status 命令验证服务是否正在运行。

## 结论

通过按照这些步骤,你可以轻松地在 Windows 中将 JetBrains Youtrack ZIP 版本作为服务运行。这种方法更可靠且易于管理。

## 常见问题解答

1. 如何修改服务脚本中的路径?

修改 $executable$args 变量以指向 Youtrack ZIP 文件中正确的文件路径。

2. 服务无法启动,显示什么错误?

检查服务脚本中的路径是否正确,确保 Youtrack ZIP 文件未损坏或移动。

3. 如何禁用服务?

使用 Disable-Service YoutrackService 命令禁用服务。

4. 如何停止服务?

使用 Stop-Service YoutrackService 命令停止服务。

5. 如何查看服务状态?

使用 Get-Service YoutrackService | Format-List Status 命令查看服务状态。