33 lines
686 B
C++
33 lines
686 B
C++
#include <fcgiapp.h>
|
|
|
|
#include <sys/stat.h>
|
|
#include <sys/types.h>
|
|
|
|
#include "server.h"
|
|
|
|
int main() {
|
|
const char* socketPath = "/run/birdbadge/birdbadge.sock";
|
|
int sockfd = FCGX_OpenSocket(socketPath, 1024);
|
|
if (sockfd < 0) {
|
|
std::cerr << "Error opening socket" << std::endl;
|
|
return 1;
|
|
}
|
|
|
|
if (chmod(socketPath, 0770) != 0) {
|
|
std::cerr << "Couldn't set socket permissions" << std::endl;
|
|
return 2;
|
|
}
|
|
|
|
Server server;
|
|
FCGX_Request request;
|
|
|
|
FCGX_Init();
|
|
FCGX_InitRequest(&request, sockfd, 0);
|
|
|
|
while (FCGX_Accept_r(&request) == 0) {
|
|
server.handleRequest(request);
|
|
|
|
FCGX_Finish_r(&request);
|
|
}
|
|
}
|