the first part of reimplementing has been done

now we have app object and singletons are only: log logn plugin and app



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@628 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2010-08-10 16:12:50 +00:00
parent 6897192364
commit 217cf1420b
191 changed files with 9529 additions and 7250 deletions

View File

@@ -1,23 +1,34 @@
# DO NOT DELETE
main.o: ../core/requestcontroller.h ../content/content.h ../core/item.h
main.o: ../templates/templates.h ../../ezc/src/ezc.h
main.o: ../templates/patterncacher.h ../templates/misc.h
main.o: ../templates/localefilter.h ../core/locale.h
main.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h
main.o: ../core/httpsimpleparser.h ../core/log.h ../templates/indexpatterns.h
main.o: ../core/thread.h ../core/ticket.h ../core/db.h ../core/item.h
main.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h
main.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h
main.o: ../core/ticket.h ../core/sessionmanager.h ../core/sessioncontainer.h
main.o: ../core/session.h ../core/rebus.h ../core/plugindata.h
main.o: ../core/functionparser.h ../core/requesttypes.h ../core/data.h
main.o: ../core/dirs.h ../core/users.h ../core/groups.h ../core/functions.h
main.o: ../core/function.h ../core/lastcontainer.h ../core/mounts.h
main.o: ../core/mount.h ../core/loadavg.h ../core/request.h
main.o: ../core/compress.h ../core/acceptencodingparser.h
main.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
main.o: ../core/postmultiparser.h ../core/config.h ../core/notify.h
main.o: ../templatesnotify/templatesnotify.h ../core/mount.h
main.o: ../templates/misc.h ../core/plugin.h ../core/request.h ../core/data.h
main.o: ../core/pluginmsg.h
main.o: ../core/log.h ../core/app.h ../core/config.h ../core/confparser.h
main.o: ../core/system.h ../core/dirs.h ../core/item.h ../core/dircontainer.h
main.o: ../core/db.h ../core/user.h ../core/group.h ../core/thread.h
main.o: ../core/error.h ../core/log.h ../core/ugcontainer.h ../core/ticket.h
main.o: ../core/request.h ../core/requesttypes.h ../core/session.h
main.o: ../core/plugindata.h ../core/rebus.h ../core/compress.h
main.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h
main.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/mounts.h
main.o: ../core/mount.h ../core/users.h ../core/lastcontainer.h
main.o: ../core/groups.h ../core/loadavg.h ../core/sessionmanager.h
main.o: ../core/sessioncontainer.h ../core/notify.h
main.o: ../templatesnotify/templatesnotify.h ../../ezc/src/ezc.h
main.o: ../core/mount.h ../core/locale.h ../core/config.h ../templates/misc.h
main.o: ../templates/localefilter.h ../core/locale.h ../functions/functions.h
main.o: ../functions/functionbase.h ../core/item.h ../core/db.h
main.o: ../core/request.h ../core/system.h ../core/notify.h
main.o: ../functions/functionparser.h ../functions/adduser.h
main.o: ../functions/cat.h ../functions/chmod.h ../functions/privchanger.h
main.o: ../functions/chown.h ../functions/cp.h ../functions/createthread.h
main.o: ../functions/createticket.h ../functions/default.h
main.o: ../functions/download.h ../functions/editticket.h
main.o: ../functions/emacs.h ../functions/last.h ../functions/login.h
main.o: ../functions/logout.h ../functions/ls.h ../functions/mkdir.h
main.o: ../functions/mv.h ../functions/node.h ../functions/priv.h
main.o: ../functions/reload.h ../functions/rm.h ../functions/run.h
main.o: ../functions/subject.h ../functions/funthread.h ../core/thread.h
main.o: ../functions/funticket.h ../functions/uname.h ../functions/upload.h
main.o: ../functions/who.h ../templates/templates.h
main.o: ../templates/patterncacher.h ../core/item.h ../templates/misc.h
main.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h
main.o: ../core/log.h ../templates/indexpatterns.h ../core/sessionmanager.h
main.o: ../core/plugin.h ../core/pluginmsg.h

View File

@@ -12,52 +12,39 @@
#include <signal.h>
#include <iostream>
#include "../core/requestcontroller.h"
#include "../core/data.h"
#include "../core/log.h"
#include "../core/request.h"
#include "../core/db.h"
#include "../core/config.h"
#include "../core/notify.h"
#include "../core/plugin.h"
#include "core/log.h"
#include "core/app.h"
#include "core/plugin.h"
// !! chwilowo
#include "core/db.h"
// singletons
// first 'data' then 'log' then 'request'
Data data;
Log log;
Log nlog; // notify log (used by another thread)
Request request;
Db db;
Config config;
RequestController req_controller;
Notify notify;
Plugin plugin;
/*
application object
*/
App app;
void signal_term(int)
{
plugin.Call(WINIX_CLOSE);
app.Close();
log << log1 << "winix stopped" << logend << logsave;
req_controller.SaveSessions();
req_controller.DeleteAllPluginsData();
log << log1 << "cmslu stopped" << logend << logsave;
// !! sprawdzic czemu ta flaga zatrzymania nie dzialala
// i sprobowac pozbyc sie tego exita tutaj
exit(0);
}
void signal_hup(int)
{
log << log1 << "SIGHUP received" << logend;
data.signal_hup = true;
//config.ReadConfig(false); /* errors not to stdout */
// plugins are not ready for reloading
}
void print_syntax()
{
@@ -77,65 +64,61 @@ int main(int argv, char ** argc)
return 1;
}
data.system_start = time(0);
data.config_file = argc[1];
app.system.system_start = time(0);
app.config.config_file = argc[1];
if( !config.ReadConfig(true) ) /* errors to stdout */
if( !app.config.ReadConfig(true, false) ) /* errors to stdout, stdout in not closed */
return 2;
if( app.stdout_is_closed )
app.config.log_stdout = false;
// closing descriptors only at the beginning
// !! temporary we do not close standard output for errors
// client postgresql uses it for reporting warnings (I don't know why)
//close(2);
if( !data.log_stdout )
if( !app.config.log_stdout )
{
close(1);
data.stdout_is_closed = true;
app.stdout_is_closed = true;
}
log.Init(data.log_level, data.log_file, data.log_stdout, data.log_request);
nlog.Init(data.log_level, data.log_notify_file, false, 1);
db.Init(data.db_database, data.db_user, data.db_pass);
log.Init(app.config.log_level, app.config.log_file, app.config.log_stdout, app.config.log_request);
nlog.Init(app.config.log_level, app.config.log_notify_file, false, 1);
app.db.Init(app.config.db_database, app.config.db_user, app.config.db_pass);
// data.base_server can be changed (stripped from 'http://' or a last slash)
// app.config.base_server can be changed (stripped from 'http://' or a last slash)
// it is done when the config is read
log << log3 << "base_server: " << data.base_server << logend;
log << log3 << "base_server: " << app.config.base_server << logend;
// load plugins before loading sessions - req_controller.LoadSessions()
plugin.LoadPlugins(data.plugin_file);
plugin.Call(WINIX_PLUGIN_INIT);
// load plugins before loading sessions - session_manager.LoadSessions()
// because some of the plugins can init your own session dates
plugin.LoadPlugins(app.config.plugin_file);
//plugin.Call(WINIX_PLUGIN_INIT);
request.Init();
if( !req_controller.Init() )
if( !app.Init() )
return 1;
// !! teraz mamy dwa katalogi z templetami
if( !notify.Init() )
return 2;
notify.ReadTemplates();
app.notify.ReadTemplates(); // wrzucic do notify.Init() ?
signal(SIGTERM, signal_term);
signal(SIGINT, signal_term);
signal(SIGHUP, signal_hup);
req_controller.LoadSessions();
log << log1 << "cmslu started" << logend << logsavenow;
log << log1 << "winix started" << logend << logsavenow;
while( true )
{
//log << log2 << "checking for table consistency:" << logend;
// !! zrobic wyjatek dla root
//db.CheckAllUrlSubject();
// !! wywalic to sprawdzanie
//log << log2 << "checking for table consistency:" << logend;
// !! zrobic wyjatek dla root
//app.db.CheckAllUrlSubject();
req_controller.Loop();
if( data.signal_hup )
data.signal_hup = false;
}
app.Start();
plugin.Call(WINIX_CLOSE);
app.Close();
log << log1 << "winix stopped" << logend << logsave;
return 0;
}