Getting work directory from websocket API

Moderators: Site Moderators, FAHC Science Team

Post Reply
arisu
Posts: 466
Joined: Mon Feb 24, 2025 11:11 pm

Getting work directory from websocket API

Post 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.
calxalot
Site Moderator
Posts: 1506
Joined: Sat Dec 08, 2007 1:33 am
Location: San Francisco, CA
Contact:

Re: Getting work directory from websocket API

Post by calxalot »

You could peek at the systemd service file on Linux.

Parsing the log sounds best.
calxalot
Site Moderator
Posts: 1506
Joined: Sat Dec 08, 2007 1:33 am
Location: San Francisco, CA
Contact:

Re: Getting work directory from websocket API

Post 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.
calxalot
Site Moderator
Posts: 1506
Joined: Sat Dec 08, 2007 1:33 am
Location: San Francisco, CA
Contact:

Re: Getting work directory from websocket API

Post by calxalot »

There might be a github issue for a command that gets all the info logged at start.
calxalot
Site Moderator
Posts: 1506
Joined: Sat Dec 08, 2007 1:33 am
Location: San Francisco, CA
Contact:

Re: Getting work directory from websocket API

Post 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.
arisu
Posts: 466
Joined: Mon Feb 24, 2025 11:11 pm

Re: Getting work directory from websocket API

Post 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.
Post Reply