Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jellyfin delayed autostart #137

Closed
ThomasPGH opened this issue Jun 29, 2024 · 1 comment · Fixed by #141
Closed

Jellyfin delayed autostart #137

ThomasPGH opened this issue Jun 29, 2024 · 1 comment · Fixed by #141

Comments

@ThomasPGH
Copy link

ThomasPGH commented Jun 29, 2024

By default and when running as a Windows service Jellyfin is very slow to start after its hosting machine is restarted.

The culprit is this line in the installer:
ExecWait '"$INSTDIR\nssm.exe" set JellyfinServer Start SERVICE_DELAYED_AUTO_START' $0

This should be:
ExecWait '"$INSTDIR\nssm.exe" set JellyfinServer Start SERVICE_AUTO_START' $0

The value SERVICE_DELAYED_AUTO_START instead of SERVICE_AUTO_START delays its service start until all other services have started, and then enters nssm's service entry routine ServiceMain () with a value of THREAD_PRIORITY_LOWEST. See https://learn.microsoft.com/en-us/windows/win32/api/winsvc/ns-winsvc-service_delayed_auto_start_info for details.

My asumption is that the SERVICE_DELAYED_AUTO_START flag got in there by accident, as I cannot imagine that someone who runs Jellyfin as a Windows service considers anything more important than starting up Jellyfin first. I reckon that just like me most users with a setup like this have a dedicated machine for Jellyfin.

@ThomasPGH
Copy link
Author

This is not required on Windows. Windows doesn't mount network attached storage. A network resource is either accessed via its UNC name (\host\share) or mapped to a drive letter.

The latter wouldn't make sense for a Windows service as this mapping is only valid for the user who created the mapping. If the software runs as a service it won't see the drive letter because the account the service runs as hasn't got it, independent on how long the service start is delayed.

A UNC share is connected to the moment it is opened. Windows might have to start other (system) services first for this to happen but that's the system's responsibility within the opening API call, for instance CreateFile (). This process is entirely hidden from an application.

Microsoft gives the reason for using SERVICE_DELAYED_AUTO_START as
"The service control manager (SCM) supports delayed auto-start services to improve system performance at boot time without affecting the user experience."

This reason doesn't hold up for users running Jellyfin as a Windows service, because if it did, they'd run the software as a tray application. For whoever runs Jellyfin via nssm there's nothing more important than firing both up as soon and as quickly as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants