2023-12-10 23:23:15 +00:00
|
|
|
// SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-11-21 22:19:08 +00:00
|
|
|
#include <fcgiapp.h>
|
|
|
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
2023-11-21 14:24:12 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
2023-12-10 23:23:15 +00:00
|
|
|
#include "config.h" //autogenereted by cmake in the root of bindir
|
|
|
|
#include "utils/helpers.h"
|
2023-11-21 22:19:08 +00:00
|
|
|
#include "server/server.h"
|
|
|
|
|
2023-12-10 23:23:15 +00:00
|
|
|
int main(int argc, char** argv) {
|
|
|
|
if (argc < 1) {
|
|
|
|
std::cerr << "Couldn't understang program path" << std::endl;
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
initPaths(argv[0]);
|
|
|
|
|
2023-11-21 22:19:08 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2023-11-23 19:57:32 +00:00
|
|
|
if (chmod(socketPath, 0777) != 0) {
|
2023-11-21 22:19:08 +00:00
|
|
|
std::cerr << "Couldn't set socket permissions" << std::endl;
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
FCGX_Init();
|
|
|
|
|
|
|
|
Server server;
|
|
|
|
server.run(sockfd);
|
2023-11-21 14:24:12 +00:00
|
|
|
}
|