FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
Dear Community User! We are updating our platform to a new
system.
Read more: Important
information on the platform change.
02-27-2024 09:15 AM
Hi everyone,
within the docs for license handling there is a note to perists the acquired license to tmpfs to prevent blocked licenses in case of a faulty app state.
Can anybody provide an example how to configure tmps within snapcraft.yaml so that the id of the acquired license can be persisted by the app?
Thanks in advance.
Regards,
Fabian
Solved! Go to Solution.
02-27-2024 10:21 AM
Hi Fabian,
you can just use /tmp in your snap as the file location. The snap is then using a for your snap specific /tmp directory, which is a subdirectory of the host’s /tmp.
I quickly tried it out with the hello.world example of the SDK to make it clearer. I added these lines to the code:
// Create and open a file
std::ofstream MyFile("/tmp/tmpfile.txt");
// Write something to the file
MyFile << "Sample Text!";
// Close the file
MyFile.close();
And then the file was created here (I logged into the ctrlX CORE virtual with ssh):
I did not need to do any changes in the snapcraf.yaml.
Best regards,
Nick
02-27-2024 11:10 AM
Hi Nick,
thanks for your suggestion.
When try to write a file directly to /tmp using a .NET-based application I get an unauthorized access exception (permission denied).
Is there anything else I have to consider?
Regards,
Fabian
02-27-2024 01:25 PM - edited 02-27-2024 01:38 PM
I just tested it also from .Net. I used the hello-world sample in .Net from the ctrlX SDK and added these lines:
...
string path = "/tmp/tmpfiledotnet.txt";
// Create the file, or overwrite if the file exists.
using (FileStream fs = File.Create(path))
{
byte[] info = new UTF8Encoding(true).GetBytes("This is some text in the file.");
// Add some information to the file.
fs.Write(info, 0, info.Length);
}
...
Except for that I did no changes. And it works like expected:
I tested everything with V2.4 (SDK and virtual ctrlX CORE). Which version did you use?
02-28-2024 08:50 AM
Hi Nick,
the issue was based on a kind of misconfiguration - everything works as expected.
As an improvement for the documentation:
It might be good for clarification to remove the reference to tmpfs if nothing is required at this point.
Regards,
Fabian