added: plugin mechanism
files: core/plugin.h core/plugin.cpp core/pluginmsg.h
added: directory 'main' with main.cpp (moved from 'core' directory)
changed: the way of building
nearly everything is in cmslu.so
only main() is in cmslu and is dynamically linked with cmslu.so
git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@516 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
22
main/Makefile
Executable file
22
main/Makefile
Executable file
@@ -0,0 +1,22 @@
|
||||
include Makefile.o.dep
|
||||
|
||||
|
||||
all: $(o)
|
||||
|
||||
|
||||
.SUFFIXES: .cpp .o
|
||||
|
||||
.cpp.o:
|
||||
$(CXX) -c $(CXXFLAGSMAIN) $<
|
||||
|
||||
|
||||
|
||||
depend:
|
||||
makedepend -Y. -f- *.cpp > Makefile.dep
|
||||
echo -n "o = " > Makefile.o.dep
|
||||
ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
|
||||
include Makefile.dep
|
||||
17
main/Makefile.dep
Executable file
17
main/Makefile.dep
Executable file
@@ -0,0 +1,17 @@
|
||||
# DO NOT DELETE
|
||||
|
||||
main.o: ../core/requestcontroller.h ../content/content.h ../core/item.h
|
||||
main.o: ../templates/templates.h ../templates/patterncacher.h
|
||||
main.o: ../core/thread.h ../core/sessionmanager.h ../core/sessioncontainer.h
|
||||
main.o: ../core/session.h ../core/done.h ../core/item.h ../core/error.h
|
||||
main.o: ../core/log.h ../core/user.h ../core/functionparser.h
|
||||
main.o: ../core/requesttypes.h ../core/data.h ../core/dirs.h
|
||||
main.o: ../core/dircontainer.h ../core/users.h ../core/ugcontainer.h
|
||||
main.o: ../core/groups.h ../core/group.h ../core/functions.h
|
||||
main.o: ../core/function.h ../core/lastcontainer.h ../core/mounts.h
|
||||
main.o: ../core/mount.h ../core/log.h ../core/request.h ../core/thread.h
|
||||
main.o: ../core/compress.h ../core/acceptencodingparser.h
|
||||
main.o: ../core/acceptbaseparser.h ../core/db.h ../core/config.h
|
||||
main.o: ../confparser/confparser.h ../core/notify.h
|
||||
main.o: ../templatesnotify/templatesnotify.h ../core/mount.h ../core/plugin.h
|
||||
main.o: ../core/request.h ../core/data.h ../core/pluginmsg.h
|
||||
1
main/Makefile.o.dep
Executable file
1
main/Makefile.o.dep
Executable file
@@ -0,0 +1 @@
|
||||
o = main.o
|
||||
127
main/main.cpp
Executable file
127
main/main.cpp
Executable file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
#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"
|
||||
|
||||
|
||||
// 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;
|
||||
|
||||
|
||||
void signal_term(int)
|
||||
{
|
||||
log << log1 << "cmslu stopped" << logend;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void signal_hup(int)
|
||||
{
|
||||
log << log1 << "SIGHUP received" << logend;
|
||||
data.signal_hup = true;
|
||||
config.ReadConfig(false); /* errors not to stdout */
|
||||
}
|
||||
|
||||
|
||||
|
||||
void print_syntax()
|
||||
{
|
||||
std::cout << "Syntax:" << std::endl;
|
||||
std::cout << " cmslu.fcgi config_file" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int main(int argv, char ** argc)
|
||||
{
|
||||
std::srand(std::time(0));
|
||||
|
||||
if( argv != 2 )
|
||||
{
|
||||
print_syntax();
|
||||
return 1;
|
||||
}
|
||||
|
||||
data.config_file = argc[1];
|
||||
|
||||
|
||||
|
||||
if( !config.ReadConfig(true) ) /* errors to stdout */
|
||||
return 2;
|
||||
|
||||
// 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 )
|
||||
{
|
||||
close(1);
|
||||
data.stdout_is_closed = true;
|
||||
}
|
||||
|
||||
|
||||
log.Init(data.log_level, data.log_file, data.log_stdout);
|
||||
nlog.Init(data.log_level, data.log_notify_file, false);
|
||||
db.Init(data.db_database, data.db_user, data.db_pass);
|
||||
|
||||
plugin.LoadPlugins(data.plugin_file);
|
||||
|
||||
request.Init();
|
||||
|
||||
if( !req_controller.Init() )
|
||||
return 1;
|
||||
|
||||
if( !notify.Init(data.templates) )
|
||||
return 2;
|
||||
|
||||
signal(SIGTERM, signal_term);
|
||||
signal(SIGINT, signal_term);
|
||||
signal(SIGHUP, signal_hup);
|
||||
|
||||
|
||||
while( true )
|
||||
{
|
||||
//log << log2 << "checking for table consistency:" << logend;
|
||||
// !! zrobic wyjatek dla root
|
||||
//db.CheckAllUrlSubject();
|
||||
|
||||
log << log1 << "cmslu started" << logend;
|
||||
|
||||
req_controller.Loop();
|
||||
|
||||
if( data.signal_hup )
|
||||
data.signal_hup = false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user