1 Star 0 Fork 4

nbsnail/ccfast

forked from zhouxiang/ccfast 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
fcgiworker.h 1.70 KB
一键复制 编辑 原始数据 按行查看 历史
zhouxiang 提交于 2015-02-26 18:27 . init project
#ifndef FCGIWORKER_H
#define FCGIWORKER_H
#include "fcgiprogram.h"
#include "ObjectCreator.h"
#include "fcgi_stdio.h"
#include <string.h>
#include "response.h"
#include <sendemail.h>
#include "util.h"
template <typename T>
///
/// \brief The FcgiWorker class,to be a ane face
/// T1 FcgiProgram subclass
///
class FcgiWorker
{
public:
FcgiWorker();
~FcgiWorker() {}
void run();
private:
boost::shared_ptr<FcgiProgram> m_fcgi;
};
template <typename T>
FcgiWorker<T>::FcgiWorker()
{
m_fcgi = ObjectCreator<T>()();
}
template <typename T>
///
/// \brief FcgiWorker<T1, T2>::run
/// anything do in run
///
void FcgiWorker<T>::run()
{
do {
try
{
m_fcgi->init();
} catch(const std::exception& ex)
{
std::cerr << ex.what() << std::endl;
std::string _message = ex.what();
_message += "<br>hostname:";
_message += get_hostname();
SendEmail::send("Fcgi_init_error!", format_send_email(_message));
break;
}
while (FCGI_Accept() >= 0)
{
try
{
m_fcgi->process();
} catch(const std::exception& ex1)
{
//print to log
std::cerr << ex1.what() << std::endl;
std::string _message = ex1.what();
_message += "<br>hostname:";
_message += get_hostname();
SendEmail::send("Fcgi_runtime_error!", format_send_email(_message));
FCGI_puts(Response::json(CODE_SYSERR, MESSAGE_SYSERR, KVList()).c_str());
break;
}
}
m_fcgi->end();
}while(true);
}
#endif // FCGIWORKER_H
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/nbsnail/ccfast.git
git@gitee.com:nbsnail/ccfast.git
nbsnail
ccfast
ccfast
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385