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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

PMS Service Blocking WSL, Plex Post Processing #73

Open
arrmo opened this issue Feb 2, 2023 · 19 comments
Open

PMS Service Blocking WSL, Plex Post Processing #73

arrmo opened this issue Feb 2, 2023 · 19 comments

Comments

@arrmo
Copy link

arrmo commented Feb 2, 2023

OK, this one is going to sound screwy, but I re-checked it today 馃槅.

I have been pulling my hair out for about a week, as my Plex Post Processing script (post DVR recording) would not properly call WSL (to run my script). Tried all sorts of things, and thing funny as it is, I did a Plex Server update - and that "hung" PmsService (other thread there). I stopped it, temporarily ran PMS manually ... and all of a sudden my post processing was working again! So I did this in a more controlled fashion ... and it turns out, running PMS via the PmsService is the underlying cause. If I run PMS "manually" (the application), then my WSL script is fine. But if PMS is started and controlled by PmsService, my script fails, with the following error when trying to call WSL,

T h e   f i l e   c a n n o t   b e   a c c e s s e d   b y   t h e   s y s t e m . 

Make any sense?

Thanks!

@ukdtom
Copy link

ukdtom commented Feb 2, 2023

Unsure, but maybe wsl needs a GUI?

@arrmo
Copy link
Author

arrmo commented Feb 2, 2023

Not thinking WSL does (though I may be wrong!), but perhaps PMS is not running "the same"? I did check the processes ... it seems to be running as the same user, and still 64 bit, but no tray icon (for PMS). Hmm.

@cjmurph
Copy link
Owner

cjmurph commented Feb 2, 2023

Does your script try to access files on a mapped drive?

@arrmo
Copy link
Author

arrmo commented Feb 2, 2023

I run a batch file (no mapped drives), that calls a script in WSL - that WSL script does call mapped drives. You suspect something? 馃槈

Thanks!

@cjmurph
Copy link
Owner

cjmurph commented Feb 2, 2023

Yep, that'll be it.
When running as a service, in session 0, drive mappings are not available. Change the path to a UNC path and it should be ok so long as the user the service is running as has the proper permissions to access the files.

@arrmo
Copy link
Author

arrmo commented Feb 2, 2023

OK, oddly enough - it even breaks if I just try to run wsl --version. Would this be expected? Meaning ... it breaks even just trying to load the mounts in /etc/fstab? Not using them, just mounting.

Thanks!

@cjmurph
Copy link
Owner

cjmurph commented Feb 2, 2023

What are the mounts?
I'm no wsl expert, but it's important to remember that all this is happening in session 0 with no user session available (hence, no mapped drives)

@arrmo
Copy link
Author

arrmo commented Feb 2, 2023

Yes, that makes sense - just want to make sure we're talking the same thing ... LOL. I have no (Windows) mapped drives in use, rather only mounts inside WSL.

Hmmm ... so I then tried a second distribution, with no mounts inside WSL - same issue, even just for wsl --version. OK, that's odd. I admit, I'm not sure what session 0 means quite yet ... LOL.

@cjmurph
Copy link
Owner

cjmurph commented Feb 2, 2023

Ok, services in windows run in session 0, which is not a user session. There is no explorer instance, so no task bar etc. Many applications require things like the taskbar, mapped drives etc so can't run in session 0. Perhaps wsl falls into this category.

@arrmo
Copy link
Author

arrmo commented Feb 2, 2023

I think you hit the nail on the head - thanks! Found this,
microsoft/WSL#9451

Hmmm. Not sure how to get around it though. Dang it!

@arrmo
Copy link
Author

arrmo commented Feb 2, 2023

Digging, but ... is there no way to spawn / launch a shell in another session? I can see from Task Manager, that when I manually run PMS, it is in Session ID 2.

Thanks!

@ukdtom
Copy link

ukdtom commented Feb 2, 2023

@arrmo
Copy link
Author

arrmo commented Feb 2, 2023

Thanks! Will do some digging in PsExec. Seems to let me set / change Session ID, just need to figure out how to set the value correctly 馃槅. And not sure if I need to change user or not.

Appreciate it!

@cjmurph
Copy link
Owner

cjmurph commented Feb 3, 2023

@arrmo can I ask, what is it you're actually trying to do with this action? Maybe there is another way to achieve this without using wsl.

@arrmo
Copy link
Author

arrmo commented Feb 3, 2023

@arrmo can I ask, what is it you're actually trying to do with this action? Maybe there is another way to achieve this without using wsl.

Sure, NP! And yes, open to suggestions - for sure.

I'm trying to run my (Plex) Post Processing script - transcode from incoming high bit rate MPEG2VIDEO (from my cable company), to lower bit rate HEVC => save storage space ... don't need to save video at ~ 18-20 Mbps on my HDD 馃槅. Plex allows me to do this - it (automatically) calls a Post Processing script before adding the newly recorded item to the library. So just trying to (re) use the script I have running on Linux - and it does work in WSL, no issues at all.

Clear as mud?

@arrmo
Copy link
Author

arrmo commented Feb 3, 2023

PsExec works! I just have to force / set the session id, so for example ... -i 2. It won't run in the console session though - thinking that may be an issue, as after reboot I won't be logged in. Hmmm. OK, have to noodle on that one a bit yet 馃槅

@cjmurph
Copy link
Owner

cjmurph commented Feb 11, 2023

I suppose you just need to be careful to ensure you kill everything, not sure what the implications of kicking off multiple user sessions, at some point you might reach a performance problem. Surely you can do this in windows natively.

@arrmo
Copy link
Author

arrmo commented Feb 12, 2023

Ya, trying to find a better way around this 馃槥. Still digging!

@arrmo
Copy link
Author

arrmo commented Feb 14, 2023

I suppose you just need to be careful to ensure you kill everything, not sure what the implications of kicking off multiple user sessions, at some point you might reach a performance problem. Surely you can do this in windows natively.

Arrgh. You would think so. Not having any luck though, even with PsExec. Like noted above, need to spawn a bat (and then bash) script, from Session ID 0. Dang it!

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

No branches or pull requests

3 participants