Linux Self Compiler Help [Resources Directory Path]


#1

As this has been confirmed by @ZappoMan - I renamed the title and set this text here to explain this is as intended

Synopsis: If the assignment-client binary is executed from another directory, it does not correctly load models.svo or backup models.svo as expected. Details Below

This is a bit long and technical so I hope it makes sense to those who it may help. On a side note if this were anything other than a test droplet (DigitalOcean) I would NOT be running it as root.

I moved binaries I compiled to their own special build location, lets say $home/hifi/run -

Directory Structure/Files

  • $home/hifi/run/assignment-client (binary)
  • $home/hifi/run/domain-server (binary)
  • $home/hifi/run/resources (folder)
  • $home/hifi/logs (folder used to store log outputs)
  • $home/hifi/run-hifi.sh (shell script)
  • $home/hifi/stop-hifi.sh (shell script)

Now you will see that run-hifi.sh is a directory below the binary directories (and the resources directory)

The shell script run-hifi.sh USED to contain this code:

#!/bin/bash

# Kills any already running services
killall -9 assignment-client > /dev/null 2>&1
killall -9 domain-server > /dev/null 2>&1

# Command to run and background each service

# Start Domain Server First
/root/hifi/run/domain-server > /root/hifi/domain.log 2>&1 &

# Start Assignment-Client Second
/root/hifi/run/assignment-client -n 4 > /root/hifi/assignment.log 2>&1 &

The problem was that the logs kept showing errors about backing up and if I placed an entity then shutdown and restarted the servers, nothing would load back because it never got saved.

After doing a bit of digging I figured out what was happening is that the assignment-client expects there to be a resources folder in the directory you are in (pwd or present working directory), not its directory like you would expect (this is where it is a potential bug).

I learned I had to do a pushd (tells the shell script to set the directory you give it as your running directory), then run the servers, then do a popd (kills the pushd directory reference).

Now that I had the directory expectations worked out I modified my shell script to be this:

#!/bin/bash

# Set directory as our "running directory"
pushd /root/hifi/run/ > /dev/null 2>&1

# Kills any already running services
killall -9 assignment-client > /dev/null 2>&1
killall -9 domain-server > /dev/null 2>&1

# Command to run and background each service

# Start Domain Server First
/root/hifi/run/domain-server > /root/hifi/logs/domain.log 2>&1 &

# Start Assignment-Client Second
/root/hifi/run/assignment-client -n 4 > /root/hifi/logs/assignment.log 2>&1 &

# unset pushd
popd > /dev/null 2>&1

Good new is now it loads models.svo correctly on load-up and stores backups

edited to fix the path from the original shell script, it was using my old directory structure, which I copied and pasted as the wrong “original” but the one now is correct as its all under /root/hifi/run/ now


#3

You can set the path to where you’d like the entities to be persisted to in the domain config. The path must exist and be writable by your process/user. As you discovered the default is “resources/models.svo” so as you noted it will try to use the path you are in when you launch the assignment client.


#4

Actually “resources” is inside the “run” directory with the assignment-client binary. When I moved the “non pushd” shell script to the “run” directory with the binaries it backs up just fine and loads the svo just fine etc.

This is why I learned that it only worked if you, as the user, executed it from within the directory the assignment-client was in.

Knowing this I tested the pushd command to tell it to use “/root/hifi/run” as running directory even though I was executing it from within “/root/hifi”.

Only when using pushd OR being inside the folder that the assignment client was in:

  • cd /root/hifi/run
  • ./assignment-client -n 4

did it work as expected.


#5

I got mine working with the following (it is a tabfile for Konsole so everything runs in different tabs of the one terminal emulator):

command: /opt/hifi/domain-server/domain-server ; profile: Shell ; title: “Domain Server”; workdir: /opt/hifi/domain-server/
command: /opt/hifi/assignment-client/assignment-client -n 4 ; profile: Shell ; title: “Assignment Client”; workdir: /opt/hifi/assignment-client/

The main point is I have explicitly set a working directory (cd-ing to the directory before executing is, I assume, much the same thing).

I also had to log into the domain-server’s web interface and set explicit paths to everything (eg /opt/hifi/assignment-client/resources/ ) before saving (and backups) worked for me.


#6

You basically did the same thing with “workdir” in your setup. You told it where to, in essence, “work from”.

In terms of pure shell scripting, you can do that by using pushd which just says “work from the directory you told me” such as

pushd /root/hifi/run

I just combined all of that into one shell script that actually points all output into a log file while backgrounding it at the same time.


#7

The default path is “resources/models.svo”. That means “starting at the current working directory, go down one directory named ‘resources’ and use the ‘models.svo’ file there.” - that is exactly how it is working as you described. So, this is not a big. This is how it’s intended to work. It works the same way on all OSes.