question

sidaigle avatar image
sidaigle asked

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

Dec 13, 2018 by: kengo.nakajima

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”


Dec 13, 2018 by: kengo.nakajima

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?


Dec 13, 2018 by: kengo.nakajima

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?


Dec 13, 2018 by: Patrick Grondin - Developer

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 1) 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.


Dec 13, 2018 by: kengo.nakajima

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


Dec 13, 2018 by: kengo.nakajima

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


Dec 13, 2018 by: kengo.nakajima

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?

60c45200-e17e-44de-a7c5-951c82d5147a.jpg


image

Dec 16, 2018 by: Sophie Isabelle Daigle - Technical Publisher & Support

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


Dec 17, 2018 by: kengo.nakajima

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.


Dec 17, 2018 by: Fabien Niñoles - CTO

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

cube samplenomadartifact
10 |600 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

0 Answers