1
0
forked from blue/pica

find fcgi is a module now, a primitive readme

This commit is contained in:
Blue 2023-11-29 10:09:11 -03:00
parent aae7873d67
commit 6909ba3138
Signed by untrusted user: blue
GPG Key ID: 9B203B252A63EE38
3 changed files with 92 additions and 4 deletions

View File

@ -8,10 +8,10 @@ cmake_policy(SET CMP0076 NEW)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
find_package(nlohmann_json REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(FCGI fcgi)
find_package(FCGI REQUIRED)
add_executable(pica main.cpp)
target_include_directories(pica PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
@ -22,8 +22,8 @@ add_subdirectory(response)
add_subdirectory(stream)
target_link_libraries(pica PRIVATE
fcgi
fcgi++
FCGI::FCGI
FCGI::FCGI++
nlohmann_json::nlohmann_json
)

60
README.md Normal file
View File

@ -0,0 +1,60 @@
# Pica - Backend for Megpie budgeting app
... some description
### Prerequisites
- fcgi
- nlohmann_json
### Building
```
$ git clone https://git.macaw.me/blue/pica
$ cd pica
$ mkdir build
$ cd build
$ cmake ..
$ cmake --build .
```
### Usage
#### Webserver
First you need a webserver. In this example I'm going to use apache.
Install apache from your package manager.
Create a file like this in apache config dir (in my case it's `/etc/httpd/conf/extra/fcgi-pica.conf`)
```
<Location /pica>
ProxyPass "unix:/run/pica/pica.sock|fcgi://localhost"
ProxyPassReverse "http://localhost"
</Location>
```
Incude this file from apache config file (in my case it's `/etc/httpd/conf/httpd.conf`)
```
Include conf/extra/fcgi-pica.conf
```
Start apache
```
$ sudo systemctl start httpd
```
#### Creating a directory
Next you need to create a directory for pica socket file
```
# mkdir /run/pica
# chown <your user> /run/pica
```
#### Running an app
At this stage we're redy to run an app
```
$ cd build
$ ./pica
```

28
cmake/FindFCGI.cmake Normal file
View File

@ -0,0 +1,28 @@
find_library(FCGI_LIBRARIES fcgi NAMES FCGI libfcgi)
find_library(FCGI++_LIBRARIES fcgi++ NAMES FCGI++ libfcgi++)
if (FCGI_LIBRARIES AND FCGI++_LIBRARIES)
set(FCGI_FOUND TRUE)
endif()
if (FCGI_FOUND)
add_library(FCGI::FCGI SHARED IMPORTED)
set_target_properties(FCGI::FCGI PROPERTIES
IMPORTED_LOCATION "${FCGI_LIBRARIES}"
INTERFACE_LINK_LIBRARIES "${FCGI_LIBRARIES}"
)
add_library(FCGI::FCGI++ SHARED IMPORTED)
set_target_properties(FCGI::FCGI++ PROPERTIES
IMPORTED_LOCATION "${FCGI++_LIBRARIES}"
INTERFACE_LINK_LIBRARIES "${FCGI++_LIBRARIES}"
)
if (NOT FCGI_FIND_QUIETLY)
message(STATUS "Found FCGI library: ${FCGI_LIBRARIES}")
message(STATUS "Found FCGI++ library: ${FCGI++_LIBRARIES}")
endif ()
else ()
if (FCGI_FIND_REQUIRED)
message(FATAL_ERROR "Could NOT find FCGI development files")
endif ()
endif ()