Breaking News on LM Studio
Breaking News on LM Studio
While testing LM Studio 0.4.25+1 with the standalone llmster service, I found that LM Studio deliberately refuses to start its desktop application when llmster is already running.
The interesting part is that LM Studio already contains a built-in way around this restriction. The internal experiment flag is named:
allowCoexistFrom my perspective, this restriction seems unnecessarily unfriendly to the end user. LM Studio is provided free of charge, so I certainly understand the developers having their own product and architectural goals. However, since the software already contains an explicit coexistence mechanism, preventing normal users from using it seems like an odd limitation.
The Fix
Edit:
C:\Users\Administrator\.lmstudio\settings.jsonUnder the existing developer section, change:
"experimentFlags": []to:
"experimentFlags": [
"allowCoexist"
]LM Studio may automatically reformat the JSON when it starts. That is normal.
Do not make this change in:
C:\Users\Administrator\.lmstudio\apps\bionic\settings.jsonWith allowCoexist enabled, LM Studio can start normally while the standalone llmster service is already running.
Windows Service
The following WinSW service configuration starts llmster at boot while still allowing LM Studio's desktop application to take over the backend later. When the service is started while LM Studio is already running, LM Studio reflects the server state in its GUI.
Files are stored in:
C:\ProgramData\LMStudio\llmster-service\Start-llmster-service.ps1
$env:USERPROFILE='C:\Users\Administrator'
$env:HOME='C:\Users\Administrator'
$env:HOMEDRIVE='C:'
$env:HOMEPATH='\Users\Administrator'
$Lms='C:\Users\Administrator\.lmstudio\bin\lms.exe'
$StopFlag='C:\ProgramData\LMStudio\llmster-service\stop.request'
$Log='C:\ProgramData\LMStudio\llmster-service\service-runner.log'
Remove-Item $StopFlag -Force -ErrorAction SilentlyContinue
"$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') Service runner starting." |
Add-Content $Log
& $Lms daemon up 2>&1 |
Add-Content $Log
Start-Sleep 3
& $Lms server start --port 1234 --bind 0.0.0.0 2>&1 |
Add-Content $Log
Start-Sleep 3
"$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') Original startup sequence complete." |
Add-Content $Log
while (-not (Test-Path $StopFlag)) {
Start-Sleep -Milliseconds 250
}
"$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') Service runner exiting." |
Add-Content $LogStop-llmster-service.ps1
$env:USERPROFILE='C:\Users\Administrator'
$env:HOME='C:\Users\Administrator'
$env:HOMEDRIVE='C:'
$env:HOMEPATH='\Users\Administrator'
$Lms='C:\Users\Administrator\.lmstudio\bin\lms.exe'
$StopFlag='C:\ProgramData\LMStudio\llmster-service\stop.request'
$Log='C:\ProgramData\LMStudio\llmster-service\service-runner.log'
"$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') Service stop requested." |
Add-Content $Log
& $Lms server stop 2>&1 |
Add-Content $Log
$StatusRaw = (& $Lms daemon status --json 2>$null | Out-String).Trim()
try {
$Status = $StatusRaw | ConvertFrom-Json
if ($Status.status -eq 'running' -and $Status.isDaemon -eq $true) {
& $Lms daemon down 2>&1 |
Add-Content $Log
"$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') Standalone llmster stopped." |
Add-Content $Log
}
else {
"$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') Desktop LM Studio backend detected; leaving LM Studio running." |
Add-Content $Log
}
}
catch {
"$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') Could not parse daemon status: $StatusRaw" |
Add-Content $Log
}
New-Item $StopFlag -ItemType File -Force |
Out-NullLMStudioLLMServer.xml
<service>
<id>LMStudioLLMServer</id>
<name>LM Studio llmster Server</name>
<description>LM Studio llmster API server</description>
<executable>powershell.exe</executable>
<startarguments>-NoProfile -ExecutionPolicy Bypass -File "C:\ProgramData\LMStudio\llmster-service\Start-llmster-service.ps1"</startarguments>
<stopexecutable>powershell.exe</stopexecutable>
<stoparguments>-NoProfile -ExecutionPolicy Bypass -File "C:\ProgramData\LMStudio\llmster-service\Stop-llmster-service.ps1"</stoparguments>
<workingdirectory>C:\ProgramData\LMStudio\llmster-service</workingdirectory>
<env name="USERPROFILE" value="C:\Users\Administrator"/>
<env name="HOME" value="C:\Users\Administrator"/>
<env name="HOMEDRIVE" value="C:"/>
<env name="HOMEPATH" value="\Users\Administrator"/>
<serviceaccount>
<username>LocalSystem</username>
</serviceaccount>
<startmode>Automatic</startmode>
<stoptimeout>30 sec</stoptimeout>
</service>The result is a boot-time LM Studio API service on port 1234, while the desktop application remains usable and can reflect/control the same backend after it is started. The key that makes the previously blocked startup possible is allowCoexist.