comparison OrthancServer/main.cpp @ 394:9784f19f7e1b lua-scripting

path relative to configuration path, list of lua scripts
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 02 May 2013 11:02:15 +0200
parents 7035f4a5b07b
children 941ea46e9e26
comparison
equal deleted inserted replaced
392:7035f4a5b07b 394:9784f19f7e1b
220 if (!isInitialized) 220 if (!isInitialized)
221 { 221 {
222 OrthancInitialize(); 222 OrthancInitialize();
223 } 223 }
224 224
225 boost::filesystem::path storageDirectory = GetGlobalStringParameter("StorageDirectory", "OrthancStorage"); 225 boost::filesystem::path storageDirectory =
226 boost::filesystem::path indexDirectory = GetGlobalStringParameter("IndexDirectory", storageDirectory.string()); 226 InterpretStringParameterAsPath(GetGlobalStringParameter("StorageDirectory", "OrthancStorage"));
227 boost::filesystem::path indexDirectory =
228 InterpretStringParameterAsPath(GetGlobalStringParameter("IndexDirectory", storageDirectory.string()));
227 ServerContext context(storageDirectory, indexDirectory); 229 ServerContext context(storageDirectory, indexDirectory);
228 230
229 LOG(WARNING) << "Storage directory: " << storageDirectory; 231 LOG(WARNING) << "Storage directory: " << storageDirectory;
230 LOG(WARNING) << "Index directory: " << indexDirectory; 232 LOG(WARNING) << "Index directory: " << indexDirectory;
231 233
232 context.SetCompressionEnabled(GetGlobalBoolParameter("StorageCompression", false)); 234 context.SetCompressionEnabled(GetGlobalBoolParameter("StorageCompression", false));
233 235
234 { 236 std::list<std::string> luaScripts;
235 std::string path = GetGlobalStringParameter("Scripting", ""); 237 GetGlobalListOfStringsParameter(luaScripts, "LuaScripts");
236 if (path.size() > 0) 238 for (std::list<std::string>::const_iterator
237 { 239 it = luaScripts.begin(); it != luaScripts.end(); it++)
238 LOG(WARNING) << "Installing the Lua scripts from: " << path; 240 {
239 std::string lua; 241 std::string path = InterpretStringParameterAsPath(*it);
240 Toolbox::ReadFile(lua, path); 242 LOG(WARNING) << "Installing the Lua scripts from: " << path;
241 context.GetLuaContext().Execute(Orthanc::EmbeddedResources::LUA_TOOLBOX); 243 std::string script;
242 context.GetLuaContext().Execute(lua); 244 Toolbox::ReadFile(script, path);
243 } 245 context.GetLuaContext().Execute(script);
244 } 246 }
245 247
246 248
247 try 249 try
248 { 250 {
281 httpServer.SetAuthenticationEnabled(GetGlobalBoolParameter("AuthenticationEnabled", false)); 283 httpServer.SetAuthenticationEnabled(GetGlobalBoolParameter("AuthenticationEnabled", false));
282 SetupRegisteredUsers(httpServer); 284 SetupRegisteredUsers(httpServer);
283 285
284 if (GetGlobalBoolParameter("SslEnabled", false)) 286 if (GetGlobalBoolParameter("SslEnabled", false))
285 { 287 {
286 std::string certificate = GetGlobalStringParameter("SslCertificate", "certificate.pem"); 288 std::string certificate =
289 InterpretStringParameterAsPath(GetGlobalStringParameter("SslCertificate", "certificate.pem"));
287 httpServer.SetSslEnabled(true); 290 httpServer.SetSslEnabled(true);
288 httpServer.SetSslCertificate(certificate.c_str()); 291 httpServer.SetSslCertificate(certificate.c_str());
289 } 292 }
290 else 293 else
291 { 294 {