File tree Expand file tree Collapse file tree 7 files changed +23
-10
lines changed
cava/samples/demo/test_program Expand file tree Collapse file tree 7 files changed +23
-10
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ project(ava)
44
55###### Options ######
66
7- set (CMAKE_BUILD_TYPE Release CACHE STRING "Build configuration (Relase /Debug)" )
7+ set (CMAKE_BUILD_TYPE Release CACHE STRING "Build configuration (Release /Debug)" )
88set_property (CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" )
99if (NOT CMAKE_BUILD_TYPE )
1010 set (CMAKE_BUILD_TYPE Release)
Original file line number Diff line number Diff line change 11all :
22 gcc -o test test.c \
33 -I../../../headers \
4- -L../../../../../ava-build/install/demo_nw /lib -ldemo \
4+ -L../../../../../ava-build/install/demo /lib -ldemo \
55 -lprotobuf
Original file line number Diff line number Diff line change @@ -2,7 +2,9 @@ Configuration Files
22===================
33
44Configuration files are replacing environment variables for AvA's settings.
5- Guestlib reads ` /etc/ava/guest.conf ` for user-defined configurations.
5+ The guestlib reads ` /etc/ava/guest.conf ` by default for user-defined configurations,
6+ this can be changed by setting the environment variable ` AVA_CONFIG_FILE_PATH `
7+ to the absolute path to a configuration file.
68
79Run ` setup.sh ` to install an example configuration.
810
Original file line number Diff line number Diff line change @@ -108,7 +108,8 @@ ls install/demo/lib
108108ls install/bin
109109```
110110
111- AvA's base repository includes a tiny standalone demo program.
111+ AvA's base repository includes a tiny standalone demo program. If compilation fails,
112+ make sure the Makefile has the correct path to the ` build ` folder.
112113
113114``` shell
114115pushd .
120121Start the demo manager by
121122
122123``` shell
123- ./install/bin/demo_manager --worker_path install/demo_nw /bin/worker
124+ ./install/bin/demo_manager --worker_path install/demo /bin/worker
124125```
125126
126127Add AvA configuration file:
@@ -132,6 +133,10 @@ manager_address = "0.0.0.0:3333";
132133gpu_memory = [1024L];
133134EOF
134135```
136+ The guestlib assumes by default the configuration file is at ` /etc/ava/guest.conf ` ,
137+ but any path can be used as long as the environment variable ` AVA_CONFIG_FILE_PATH `
138+ is exported and contains the absolute path to the configuration file.
139+
135140
136141Run the test program by
137142
Original file line number Diff line number Diff line change @@ -6,13 +6,17 @@ namespace guestconfig {
66
77std::shared_ptr<GuestConfig> config;
88
9+ char *getConfigFilePath () {
10+ return std::getenv (" AVA_CONFIG_FILE_PATH" ) ? std::getenv (" AVA_CONFIG_FILE_PATH" ) : (char *)kDefaultConfigFilePath ;
11+ }
12+
913std::shared_ptr<GuestConfig> readGuestConfig () {
1014 libconfig::Config cfg;
1115
1216 try {
13- cfg.readFile (guestconfig::kConfigFilePath );
17+ cfg.readFile (guestconfig::getConfigFilePath () );
1418 } catch (const libconfig::FileIOException &fioex) {
15- std::cerr << " I/O error when reading " << guestconfig::kConfigFilePath << std::endl;
19+ std::cerr << " I/O error when reading " << guestconfig::getConfigFilePath () << std::endl;
1620 return nullptr ;
1721 } catch (const libconfig::ParseException &pex) {
1822 std::cerr << " Parse error at " << pex.getFile () << " :" << pex.getLine () << " - " << pex.getError () << std::endl;
Original file line number Diff line number Diff line change 1111
1212namespace guestconfig {
1313
14- constexpr char kConfigFilePath [] = " /etc/ava/guest.conf" ;
14+ constexpr char kDefaultConfigFilePath [] = " /etc/ava/guest.conf" ;
1515constexpr char kDefaultChannel [] = " TCP" ;
1616constexpr uint64_t kDefaultConnectTimeout = 5000 ;
1717constexpr char kDefaultManagerAddress [] = " 0.0.0.0:3334" ;
@@ -49,6 +49,8 @@ class GuestConfig {
4949 plog::Severity logger_severity_;
5050};
5151
52+ char *getConfigFilePath ();
53+
5254std::shared_ptr<GuestConfig> readGuestConfig ();
5355
5456extern std::shared_ptr<GuestConfig> config;
Original file line number Diff line number Diff line change @@ -48,8 +48,8 @@ EXPORTED_WEAKLY void nw_init_guestlib(intptr_t api_id) {
4848 // } else if (guestconfig::config->channel_ == "VSOCK") {
4949 // chan = command_channel_socket_new();
5050 } else {
51- std::cerr << " Unsupported channel specified in " << guestconfig::kConfigFilePath << " , expect channel = [ \" TCP \" ] "
52- << std::endl;
51+ std::cerr << " Unsupported channel specified in " << guestconfig::getConfigFilePath ()
52+ << " , expect channel = [ \" TCP \" ] " << std::endl;
5353 exit (0 );
5454 }
5555 if (!chan) {
You can’t perform that action at this time.
0 commit comments