pica/main.cpp

40 lines
915 B
C++

// SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
// SPDX-License-Identifier: GPL-3.0-or-later
#include <fcgiapp.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <iostream>
#include "config.h" //autogenereted by cmake in the root of bindir
#include "utils/helpers.h"
#include "server/server.h"
int main(int argc, char** argv) {
if (argc < 1) {
std::cerr << "Couldn't understang program path" << std::endl;
return 3;
}
initPaths(argv[0]);
const char* socketPath = "/run/pica/pica.sock";
int sockfd = FCGX_OpenSocket(socketPath, 1024);
if (sockfd < 0) {
std::cerr << "Error opening socket" << std::endl;
return 1;
}
if (chmod(socketPath, 0777) != 0) {
std::cerr << "Couldn't set socket permissions" << std::endl;
return 2;
}
FCGX_Init();
Server server;
server.run(sockfd);
}