Commit aaef36b8 by guanghui.cui

程序启动后,pid写入配置文件(程序更新时需要,如果不写入,程序更新后程序重启,pid和守护进程记录的不一致,造成守护进程无法监控程序的问题)

parent ae18c821
......@@ -6,12 +6,14 @@
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/syscall.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <pthread.h>
#include <ifaddrs.h>
#include <string.h>
#include <fstream>
#include "../base/FM_ErrorCode.h"
#include "SQLiteOperate.h"
#include "PayProcess.h"
......@@ -22,7 +24,7 @@
#define ELPP_NO_DEFAULT_LOG_FILE
#include "../3rdParty/easylogging/easylogging++.h"
using namespace std;
#define BUFFER_SIZE 1024 //缓冲区大小
void InitSystem();
void Init();
......@@ -64,6 +66,14 @@ int main()
//SetUnhandledExceptionFilter(FMExcpHandler);
signal(SIGINT, app_stopped);
LOG(INFO)<<"启动 FMDbMonitor";
pid_t tid;
tid = syscall(SYS_gettid);
std::string strPidPath = GetProcDir();
strPidPath.append("pidMonitor.txt");
LOG(INFO)<<"get process pid:"<<tid<<" file name:"<<strPidPath.data();
fstream f(strPidPath.c_str(),ios::out);
f<<tid;
f.close();
int nrlt = EC_OK;
while (dbOperation->DBConnect()!= EC_OK)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment