Genvid Forum

Genvid Technologies

How to change game's current working directory in game.hcl


#1

In my game.hcl, I have this path of the executable:

path = “{{env PROJECTDIR | js}}\app\ssg\Debug\ssg.exe”

It looks that working direectory of ssg.exe is in the same directory of ssg.exe .
How can I change working dir of it?
I want to configure it with like:

workdir = “{{env PROJECTDIR |js }}\app\ssg”


#2

I noticed that working directory is located here:

C:\Users\Administrator.genvid\nomad\data\alloc\d795a3bd-3fbb-1e8b-06aa-c4331636af6c\tutorial

I have to copy assets directory to the place. how to do it?


#3

in another project that I could run is running in:
C:\Genvid\1.19.0\samples\tutorial\app\moyai\demowin\Debug

Both are obtained by GetCurrentDirectory() windows API. What are difference?


#4

Hi Nakajima-san!

You would usually get to deploy assets in the working directory through the artifacts instruction in Nomad in the job definition. (https://www.nomadproject.io/docs/job-specification/artifact.html) Jobs definitions in the Genvid stack are defined in the templates directory.

The […]\nomad\data[uuid]\tutorial location will be dynamically allocated (the UUID part) on job creation and will be populated with the artifacts. Every time you stop/start a job in Nomad it will get a new allocation so you shouldn’t copy files directly to that folder.

I hope it can help you get a little further for now. If you have other questions. don’t hesitate.


#5

where can I find artifact settings for default tutorial cube sample program?


#6

I looked at tutorial.nomad.tmpl but cant find artifact directive.
Is there any other examples in SDK?


#7

I have 3 programs, one is SDK’s tutorial,
one is in “moyai” directory, one is in “ssg” directory, as seen in screenshot.

demowin.exe and tutorial.exe is running correctly if I comment-in/out these lines, and it prints “C:\Genvid\1.19.0\samples\tutorial\app…” path, but only ssg.exe prints C:\Users\Administrator.genvid\nomad\data\alloc\d795a3bd-3fbb-1e8b-06aa-c4331636af6c\tutorial …

I am changing only program name here, but the SDK works very differently.
What is happening?


#8

Hi Nakajima-san,

If we understand correctly, it appears you are trying to have the workdir environment variable set to the same location the executable will run from.

There are 2 things to keep in mind:

  1. The game.hcl will set values in Consul that will later be used by the template (in this case the tutorial executable path).
  2. The tutorail.nomad.tmpl then use that value as the command to run.

From what we are seeing, you seem to be using the local template.
Since you are using the local template, there is no artifact stanza. One can be found on the cloud template.

If indeed the goal is to have the workdir environment set when running the game, then this can be set in tutorial.nomad.tmpl, in the “env” section.

The TUTORIAL_CWD environment seems to be containing the location where the app is run.

Additionally, the executable is not copied in the local cluster, it is run in its original location.

Please let us know if this helps.

Thanks!
Sophie


#9

thanks, I only changed game.hcl 's config.local.binary.tutorial.path, but
the program prints different current directory with this code:

void printExeFileName()
{
#ifdef USE_GENVID
TCHAR path[MAX_PATH + 1] = L"";
DWORD len = GetCurrentDirectory(MAX_PATH, path);

OutputDebugString(path);
std::wcerr << L"path: " << path << ‘\n’;
#endif
}

My another program prints local path correctly.


#10

Hi Nakajima-san.
Nomad raw-exec driver always changed the working directory to the allocation directory, and run the command line in the job definition.

In local mode, we try to avoid copying the game, since it’s a dev environment. Instead, we set a variable (TUTORIAL_CWD) to where the game can find its assets.

Hope this help,
Fabien