mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-14 14:22:35 -06:00
Skylark: SigUsr1 handler
git-svn-id: svn://ultimatepp.org/upp/trunk@5337 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
4283a1f9d7
commit
0b5807aaaa
3 changed files with 114 additions and 100 deletions
|
|
@ -118,6 +118,10 @@ void SkylarkApp::Signal(int signal)
|
|||
Broadcast(signal);
|
||||
exit(0);
|
||||
break;
|
||||
case SIGUSR1:
|
||||
Broadcast(signal);
|
||||
SigUsr1();
|
||||
break;
|
||||
case SIGALRM:
|
||||
if(getpid() != TheApp().main_pid) {
|
||||
// "Timeout - session stoped"
|
||||
|
|
@ -239,6 +243,9 @@ void SkylarkApp::Run()
|
|||
SKYLARKLOG("ExitSkylark");
|
||||
}
|
||||
|
||||
void SkylarkApp::SigUsr1()
|
||||
{
|
||||
}
|
||||
|
||||
void SkylarkApp::SqlError(Http& http)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,99 +1,101 @@
|
|||
#ifndef _Skylark_Skylark_h
|
||||
#define _Skylark_Skylark_h
|
||||
|
||||
#include <Sql/Sql.h>
|
||||
|
||||
namespace Upp {
|
||||
|
||||
namespace Ini {
|
||||
extern IniBool skylark_log;
|
||||
};
|
||||
|
||||
String GetThreadName();
|
||||
|
||||
#define SKYLARKLOG(x) LOG_(Ini::skylark_log, GetThreadName() << ' ' << x)
|
||||
|
||||
class Renderer;
|
||||
class Http;
|
||||
|
||||
struct SkylarkSessionConfig {
|
||||
String cookie;
|
||||
String dir;
|
||||
int format;
|
||||
SqlId table, id_column, data_column, lastwrite_column;
|
||||
int expire;
|
||||
|
||||
SkylarkSessionConfig();
|
||||
};
|
||||
|
||||
struct AuthExc : Exc {
|
||||
AuthExc(const String& s) : Exc(s) {}
|
||||
};
|
||||
|
||||
struct BadRequestExc : Exc {};
|
||||
|
||||
struct SkylarkConfig {
|
||||
String root;
|
||||
VectorMap<String, String> view_var;
|
||||
String path;
|
||||
String static_dir;
|
||||
SkylarkSessionConfig session;
|
||||
int threads;
|
||||
int port;
|
||||
int prefork;
|
||||
int timeout;
|
||||
bool use_caching;
|
||||
};
|
||||
|
||||
class SkylarkApp : protected SkylarkConfig {
|
||||
TcpSocket server;
|
||||
Mutex accept_mutex;
|
||||
int main_pid;
|
||||
Vector<int> child_pid;
|
||||
bool quit;
|
||||
|
||||
|
||||
void ThreadRun();
|
||||
void Broadcast(int signal);
|
||||
void Signal(int signal);
|
||||
static void SignalHandler(int signal);
|
||||
void Main();
|
||||
|
||||
void FinalizeViews();
|
||||
|
||||
static SkylarkApp *app;
|
||||
|
||||
#ifdef PLATFORM_WIN32
|
||||
static BOOL WINAPI CtrlCHandlerRoutine(__in DWORD dwCtrlType);
|
||||
#endif
|
||||
|
||||
typedef SkylarkApp CLASSNAME;
|
||||
|
||||
friend class Http;
|
||||
|
||||
public:
|
||||
virtual void SqlError(Http& http);
|
||||
virtual void InternalError(Http& http);
|
||||
virtual void NotFound(Http& http);
|
||||
virtual void Unauthorized(Http& http);
|
||||
virtual void BadRequest(Http& http);
|
||||
|
||||
virtual void WorkThread();
|
||||
|
||||
void RunThread();
|
||||
|
||||
void Run();
|
||||
|
||||
static SkylarkApp& TheApp();
|
||||
static const SkylarkConfig& Config();
|
||||
|
||||
SkylarkApp();
|
||||
virtual ~SkylarkApp();
|
||||
};
|
||||
|
||||
#include "Witz.h"
|
||||
#include "Http.h"
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef _Skylark_Skylark_h
|
||||
#define _Skylark_Skylark_h
|
||||
|
||||
#include <Sql/Sql.h>
|
||||
|
||||
namespace Upp {
|
||||
|
||||
namespace Ini {
|
||||
extern IniBool skylark_log;
|
||||
};
|
||||
|
||||
String GetThreadName();
|
||||
|
||||
#define SKYLARKLOG(x) LOG_(Ini::skylark_log, GetThreadName() << ' ' << x)
|
||||
|
||||
class Renderer;
|
||||
class Http;
|
||||
|
||||
struct SkylarkSessionConfig {
|
||||
String cookie;
|
||||
String dir;
|
||||
int format;
|
||||
SqlId table, id_column, data_column, lastwrite_column;
|
||||
int expire;
|
||||
|
||||
SkylarkSessionConfig();
|
||||
};
|
||||
|
||||
struct AuthExc : Exc {
|
||||
AuthExc(const String& s) : Exc(s) {}
|
||||
};
|
||||
|
||||
struct BadRequestExc : Exc {};
|
||||
|
||||
struct SkylarkConfig {
|
||||
String root;
|
||||
VectorMap<String, String> view_var;
|
||||
String path;
|
||||
String static_dir;
|
||||
SkylarkSessionConfig session;
|
||||
int threads;
|
||||
int port;
|
||||
int prefork;
|
||||
int timeout;
|
||||
bool use_caching;
|
||||
};
|
||||
|
||||
class SkylarkApp : protected SkylarkConfig {
|
||||
TcpSocket server;
|
||||
Mutex accept_mutex;
|
||||
int main_pid;
|
||||
Vector<int> child_pid;
|
||||
bool quit;
|
||||
|
||||
|
||||
void ThreadRun();
|
||||
void Broadcast(int signal);
|
||||
void Signal(int signal);
|
||||
static void SignalHandler(int signal);
|
||||
void Main();
|
||||
|
||||
void FinalizeViews();
|
||||
|
||||
static SkylarkApp *app;
|
||||
|
||||
#ifdef PLATFORM_WIN32
|
||||
static BOOL WINAPI CtrlCHandlerRoutine(__in DWORD dwCtrlType);
|
||||
#endif
|
||||
|
||||
typedef SkylarkApp CLASSNAME;
|
||||
|
||||
friend class Http;
|
||||
|
||||
public:
|
||||
virtual void SigUsr1();
|
||||
|
||||
virtual void SqlError(Http& http);
|
||||
virtual void InternalError(Http& http);
|
||||
virtual void NotFound(Http& http);
|
||||
virtual void Unauthorized(Http& http);
|
||||
virtual void BadRequest(Http& http);
|
||||
|
||||
virtual void WorkThread();
|
||||
|
||||
void RunThread();
|
||||
|
||||
void Run();
|
||||
|
||||
static SkylarkApp& TheApp();
|
||||
static const SkylarkConfig& Config();
|
||||
|
||||
SkylarkApp();
|
||||
virtual ~SkylarkApp();
|
||||
};
|
||||
|
||||
#include "Witz.h"
|
||||
#include "Http.h"
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -20,12 +20,17 @@ and changing Skylark configuration, which should be only done
|
|||
in SkylarkApp constructor.&]
|
||||
[s0;i448;a25;kKO9;:noref:@(0.0.255)%- &]
|
||||
[ {{10000F(128)G(128)@1 [s0; [* Public Method List]]}}&]
|
||||
[s3; &]
|
||||
[s5;:SkylarkApp`:`:SigUsr1`(`):%- [@(0.0.255) virtual] [@(0.0.255) void]_[* SigUsr1]()&]
|
||||
[s2; Invoked when application recieves SIGUSR1 signal. Default implementation
|
||||
is empty&]
|
||||
[s3;%- &]
|
||||
[s4;%- &]
|
||||
[s5;:SkylarkApp`:`:SqlError`(Http`&`):%- [@(0.0.255) virtual] [@(0.0.255) void]_[* SqlError
|
||||
]([_^Http^ Http][@(0.0.255) `&]_[*@3 http])&]
|
||||
[s2; Overriding this method can change the response in case that
|
||||
there was SQL error in handler.&]
|
||||
[s3; &]
|
||||
[s3;%- &]
|
||||
[s4; &]
|
||||
[s5;:SkylarkApp`:`:InternalError`(Http`&`):%- [@(0.0.255) virtual]
|
||||
[@(0.0.255) void]_[* InternalError]([_^Http^ Http][@(0.0.255) `&]_[*@3 http])&]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue