Page 1 of 1

Getting work directory from websocket API

Posted: Sun May 04, 2025 1:38 pm
by arisu
Is there any way, using the websocket API, to find out the location of the work directory? The config state that is sent upon initial connection to the websocket contains a lot of information, but it doesn't contain the configured work directory nor the client's current PID. I've been trying to find some way to determine it without needing to hardcode /var/lib/fah-client in my scripts.

I could send the "log" command and then parse the logs manually to find the lines that start with "CWD", but that only works if there are WUs running.

I tried to find the CWD of the client's PID, and find the client's PID based on the listening port, but it turns out I'd need root to do that when fah-client runs as its own user, which it does. So I'm out of ideas.

Re: Getting work directory from websocket API

Posted: Sun May 04, 2025 7:52 pm
by calxalot
You could peek at the systemd service file on Linux.

Parsing the log sounds best.

Re: Getting work directory from websocket API

Posted: Sun May 04, 2025 7:57 pm
by calxalot
A log header should exist even if no WUs are running. The log start might be gone after 100000 lines have been cached by the client.

If web control shows it, you should see it.

Re: Getting work directory from websocket API

Posted: Sun May 04, 2025 8:00 pm
by calxalot
There might be a github issue for a command that gets all the info logged at start.

Re: Getting work directory from websocket API

Posted: Sun May 04, 2025 8:16 pm
by calxalot
Since you have built your own client, you could add a command to return the cwd.

Or you could stuff the cwd and whatever else you want in the state “info” dictionary.

If someone is running under their home directory, you could be leaking a system user name.

Re: Getting work directory from websocket API

Posted: Mon May 05, 2025 1:00 am
by arisu
Since it's on my own system, I already know that I keep it in /var/lib/fah-client. This is more for completeness sake and for some scripts I may make more useful to the average person and make public. In particular, a script that dumps an ungodly amount of information about a running WU which may be interesting to some people. But to be able to work best, it needs to know where the client database is and where the work directory is.