Thread: [Cppcms-users] Reload views from .so
Brought to you by:
artyom-beilis
From: Marcel H. <ke...@co...> - 2011-11-29 20:23:50
|
Hi guys, i really love this framework and although I'm still learning CPP it's great. The performance is... awesome! :) Big contrast to PHP or Tomcat. So my question. I'd like to run the server and from time to time I'd like to change the pages, but without resetting the server, so I thought I'm putting some signal handler, which will reload all the views when they get a SIGUSR1. I looked into the source and found, that you will check in "views_pool.cpp:331" if the config auto_reload flag is true. So I thought it would be awesome, if you could outsource the thing where you reload the files into a method you can call from the outside if you want to. (wow, 4 times you in one sentence) What is your opinion. Worth a try? |
From: Artyom B. <art...@ya...> - 2011-11-29 20:54:36
|
Hello, Two points: 1. If auto_reload is true the views would be automatically reloaded if the shared object had changed. So anything you need to do is to replace a shared object with a new one. This method is thread safe but has some performance penalty (it requires checking file timestamp each time the template is rendered) 2. You can manually load and unload shared object upon signal you get but this may be not thread safe so you need to make sure nothing happens. Such that if some thread renders HTML and you unload shared object bad things can happen. See: http://art-blog.no-ip.info/wikipp/en/page/cppcms_1x_config#views.auto_reload Does this fits you needs? Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.sf.net/ CppDB - C++ SQL Connectivity: http://cppcms.sf.net/sql/cppdb/ ----- Original Message ----- > From: Marcel Hellwig <ke...@co...> > To: cpp...@li... > Cc: > Sent: Tuesday, November 29, 2011 10:23 PM > Subject: [Cppcms-users] Reload views from .so > > Hi guys, > > i really love this framework and although I'm still learning CPP it's > great. The performance is... awesome! :) Big contrast to PHP or Tomcat. > So my question. I'd like to run the server and from time to time I'd > like to change the pages, but without resetting the server, so I thought > I'm putting some signal handler, which will reload all the views when > they get a SIGUSR1. I looked into the source and found, that you will > check in "views_pool.cpp:331" if the config auto_reload flag is true. > So > I thought it would be awesome, if you could outsource the thing where > you reload the files into a method you can call from the outside if you > want to. (wow, 4 times you in one sentence) > What is your opinion. Worth a try? > > > ------------------------------------------------------------------------------ > All the data continuously generated in your IT infrastructure > contains a definitive record of customers, application performance, > security threats, fraudulent activity, and more. Splunk takes this > data and makes sense of it. IT sense. And common sense. > http://p.sf.net/sfu/splunk-novd2d > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |
From: Marcel H. <ke...@co...> - 2011-11-30 07:12:33
|
no :) I mean, that you can manually say, reload now! and he reloads. Maybe it would be good enough if I set the boolean to true and afterwards back to false, but it would be a nice option to say, reload the next time the librarys but do not check always, because, you said it, of performance. Maybe something like this: render().reloadLibrary(); and then he will set a flag and reloads the librarys but only once. Get it? |
From: kpeo <sla...@ya...> - 2011-11-30 08:58:34
|
Hello, imho, it would make sense if you want to reload a library with a different name, like "load_view('lib')" where pattern in config applies to this name. checking of file timestamp is not so critical for performance. 30.11.2011, 11:12, "Marcel Hellwig" <ke...@co...>: > no :) > I mean, that you can manually say, reload now! and he reloads. Maybe it > would be good enough if I set the boolean to true and afterwards back to > false, but it would be a nice option to say, reload the next time the > librarys but do not check always, because, you said it, of performance. > Maybe something like this: > > render().reloadLibrary(); > > and then he will set a flag and reloads the librarys but only once. Get it? > > ------------------------------------------------------------------------------ > All the data continuously generated in your IT infrastructure > contains a definitive record of customers, application performance, > security threats, fraudulent activity, and more. Splunk takes this > data and makes sense of it. IT sense. And common sense. > http://p.sf.net/sfu/splunk-novd2d > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users |
From: Artyom B. <art...@ya...> - 2011-11-30 12:12:16
|
----- Original Message ----- > From: Marcel Hellwig <ke...@co...> > To: Artyom Beilis <art...@ya...>; cpp...@li... > Cc: > Sent: Wednesday, November 30, 2011 9:12 AM > Subject: Re: [Cppcms-users] Reload views from .so > > no :) > I mean, that you can manually say, reload now! and he reloads. Maybe it > would be good enough if I set the boolean to true and afterwards back to > false, but it would be a nice option to say, reload the next time the > librarys but do not check always, because, you said it, of performance. > Maybe something like this: > > render().reloadLibrary(); > > and then he will set a flag and reloads the librarys but only once. Get it? > Few points. 1. Providing thread safe reload library would have almost the same performance penalty. In order to make it thread safe you need to acquire Read Lock on some R/W mutex. Checking the time-stamp requires small resources as well. So I don't what is the difference it can make. 2. First check how auto_reload option affects the performance if significantly then it may make sense to do something about but if it does not... Don't bother use auto_reload, I don't think it would be that bad. So if you want to switch the library just execute "move" on the shared object replacing it with new one and CppCMS would reload it automatically. Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.sf.net/ CppDB - C++ SQL Connectivity: http://cppcms.sf.net/sql/cppdb/ |