-
Notifications
You must be signed in to change notification settings - Fork 18
170 lines (136 loc) · 5.63 KB
/
server_installer_windows_latest.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: Server Installer Windows-Latest Build and Test
on:
push:
branches: ["main"]
tags:
- v*
pull_request:
branches: ["main"]
workflow_dispatch:
jobs:
make-server-installer:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Install NSIS
shell: PowerShell
run: |
# Download NSIS installer
Invoke-WebRequest -UserAgent "Wget" -Uri "https://sourceforge.net/projects/nsis/files/NSIS%203/3.10/nsis-3.10-setup.exe" -OutFile "nsis.exe"
# Install NSIS
Start-Process nsis.exe -ArgumentList '/S' -Wait
- name: Verify NSIS installation
shell: PowerShell
run: |
# Check if NSIS is installed
& 'C:\Program Files (x86)\NSIS\makensis.exe' /VERSION
- name: Build the Lemonade Server installer
shell: PowerShell
run: |
cd installer
& 'C:\Program Files (x86)\NSIS\makensis.exe' 'Installer.nsi'
if (Test-Path "Lemonade_Server_Installer.exe") {
Write-Host "Lemonade_Server_Installer.exe has been created successfully."
} else {
Write-Host "Lemonade_Server_Installer.exe was not found."
exit 1
}
- name: Upload Installer
uses: actions/upload-artifact@v4
if: always()
with:
name: LemonadeServerInstaller
path: |
installer\Lemonade_Server_Installer.exe
- name: Attempt to install Lemonade Server using installer
shell: cmd
run: |
cd installer
Lemonade_Server_Installer.exe /S
- name: Ensure the Lemonade serer works properly
shell: pwsh
run: |
Write-Host "Use a function to determine the underlying command from the lemonade server shortcut"
function Get-ShortcutTarget {
param (
[string]$shortcutPath
)
$shell = New-Object -ComObject WScript.Shell
$shortcut = $shell.CreateShortcut($shortcutPath)
$targetPath = $shortcut.TargetPath
$arguments = $shortcut.Arguments
return "$targetPath $arguments"
}
Write-Host "ls of install directory to make sure the server is there"
ls "$HOME\AppData\Local\lemonade_server"
$shortcutPath = "$HOME\AppData\Local\lemonade_server\lemonade-server.lnk"
$fullCommand = Get-ShortcutTarget -shortcutPath $shortcutPath
Write-Host "Server shortcut full command: $fullCommand"
$quotedCommand = "`"$fullCommand`""
$outputFile = "output.log"
$errorFile = "error.log"
$serverProcess = Start-Process -FilePath "cmd.exe" -ArgumentList "/C $quotedCommand" -RedirectStandardOutput $outputFile -RedirectStandardError $errorFile -PassThru -NoNewWindow
Write-Host "Wait for 30 seconds to let the server come up"
Start-Sleep -Seconds 30
Write-Host "Check if server process successfully launched"
$serverRunning = Get-Process -Id $serverProcess.Id -ErrorAction SilentlyContinue
if (-not $serverRunning) {
Write-Host "Error: Server process isn't running, even though we just tried to start it!"
Write-Host "Standard Output:"
Get-Content $outputFile
Write-Host "Standard Error:"
Get-Content $errorFile
exit 1
} else {
Write-Host "Server process is alive."
}
Write-Host "Wait for the server port to come up"
while ($true) {
$llmPortCheck = Test-NetConnection -ComputerName 127.0.0.1 -Port 8000
if (-not $llmPortCheck.TcpTestSucceeded) {
Write-Host "LLM server is not yet running on port 8000!"
Write-Host "Standard Output:"
Get-Content $outputFile
Write-Host "Standard Error:"
Get-Content $errorFile
} else {
Write-Host "LLM server is running on port 8000."
break
}
Start-Sleep -Seconds 30
}
Write-Host "Checking the /health endpoint"
$response = Invoke-WebRequest -Uri http://localhost:8000/api/v0/health -UseBasicParsing
if ($response.StatusCode -eq 200) {
Write-Output "Good: /health status code is 200"
} else {
Write-Output "Error: /health status code is not 200"
Write-Host "Standard Output:"
Get-Content $outputFile
Write-Host "Standard Error:"
Get-Content $errorFile
exit 1
}
$jsonContent = $response.Content | ConvertFrom-Json
if ($jsonContent) {
Write-Output "Good: /health JSON content is not empty: $jsonContent"
} else {
Write-Output "Error: /health JSON content is empty"
Write-Host "Standard Output:"
Get-Content $outputFile
Write-Host "Standard Error:"
Get-Content $errorFile
exit 1
}
Write-Host "Close the server process"
function Kill-Tree {
Param([int]$ppid)
Get-CimInstance Win32_Process | Where-Object { $_.ParentProcessId -eq $ppid } | ForEach-Object { Kill-Tree $_.ProcessId }
Stop-Process -Id $ppid
}
Kill-Tree $serverProcess.Id
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/v')
with:
files: installer/Lemonade_Server_Installer.exe