... | ... | @@ -89,11 +89,47 @@ If your app has a graphical user interface, you may need to check the variable * |
|
|
|
|
|
One practical way to check the required environment variables is to launch the app in a working environment e.g. on a local account and print the list of environment variables.
|
|
|
|
|
|
# Log, standard error and output
|
|
|
# Log
|
|
|
|
|
|
The Cameo server application is logging in the *cameo.log* file and it is also possible to log the standard error and output of the applications started by the Cameo server.
|
|
|
|
|
|
Indeed when you need to debug an application, the standard error and output may be useful.
|
|
|
Cameo applications are started in background and it is possible to log the standard error and output. For that, you need to define the *log_directory* attribute of the application tag with a path that exists or the *default* value which is the location of the *cameo.log* file. Each running Cameo application has a unique id provided by the server and the produced log file is *<name>.<id>.log* for an app with the name *name* and id *id*. For instance it could be *App2.12.log*.
|
|
|
|
|
|
The standard error and output can also be printed by the console application or retrieved by the API. For that the attribute *stream* must have be set to *yes*. |
|
|
# Standard error and output
|
|
|
|
|
|
The standard error and output can also be printed by the console application or retrieved by the API. For that the attribute *stream* must have be set to *yes*. An example with the C++ API:
|
|
|
```cpp
|
|
|
// Start the app with the OUTPUTSTREAM option.
|
|
|
std::unique_ptr<cameo::application::Instance> app = server.start("App2", cameo::OUTPUTSTREAM);
|
|
|
|
|
|
// Get the outputstream socket.
|
|
|
std::shared_ptr<cameo::OutputStreamSocket> socket = app->getOutputStreamSocket();
|
|
|
|
|
|
// Define a thread to retrieve the output.
|
|
|
std::thread outputThread([&] {
|
|
|
while (true) {
|
|
|
std::optional<Output> output = socket->receive();
|
|
|
if (output) {
|
|
|
std::cout << output.value().getMessage() << std::endl;
|
|
|
}
|
|
|
else {
|
|
|
// The socket has terminated normally or was canceled.
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// Wait for 1s.
|
|
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
|
|
|
|
|
// Stop the output stream socket.
|
|
|
socket->cancel();
|
|
|
|
|
|
// Wait for the end of the thread.
|
|
|
outputThread.join();
|
|
|
```
|
|
|
|
|
|
Starting the application with the option *OUTPUTSTREAM* creates an output stream socket so that all the stream can be retrieved.
|
|
|
|
|
|
|