Magpie backend
Go to file
2023-12-22 20:25:20 -03:00
cmake first what so ever registration 2023-12-20 19:42:13 -03:00
database password hash cheching 2023-12-22 20:25:20 -03:00
handler password hash cheching 2023-12-22 20:25:20 -03:00
request password hash cheching 2023-12-22 20:25:20 -03:00
response password hash cheching 2023-12-22 20:25:20 -03:00
server password hash cheching 2023-12-22 20:25:20 -03:00
stream just some thoughts 2023-12-11 20:29:55 -03:00
utils some thinking around passing the form 2023-12-14 19:17:28 -03:00
CMakeLists.txt first what so ever registration 2023-12-20 19:42:13 -03:00
config.h.in just some thoughts 2023-12-11 20:29:55 -03:00
CONTRIBUTORS.md licensed, a bit better file handling, a bit better migration handling 2023-12-10 20:23:15 -03:00
LICENSE.md licensed, a bit better file handling, a bit better migration handling 2023-12-10 20:23:15 -03:00
main.cpp licensed, a bit better file handling, a bit better migration handling 2023-12-10 20:23:15 -03:00
README.md first what so ever registration 2023-12-20 19:42:13 -03:00

Pica - Backend for Megpie budgeting app

... some description

Prerequisites

  • fcgi
  • nlohmann_json
  • mariadb-client
  • argon2

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 (apache2, httpd) 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>
    <IfModule mod_headers.c>
        Header set Access-Control-Allow-Origin "*"
        Header set Access-Control-Allow-Headers: "*"
    </IfModule>

    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

Also you need to have 3 modules enabled:

  • proxy
  • proxy_fcgi
  • headers

Usually you need to uncomment following lines in /etc/httpd/conf/httpd.conf

LoadModule headers_module modules/mod_headers.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so

In case you use debian-like distro (ubuntu) you should use a2enmod command instead:

# a2enmod proxy_fcgi

This should enable all modules, because module proxy_fcgi has module proxy as a dependency, and headers are supposed to be enabled.

Start apache

$ sudo systemctl start httpd

Database

You're also goint to need a database server. For now only MySQL/Mariadb is supported. I'm going to use Mariadb as an example.

First - install mariadb (the server!). Set it up, edit config, run whatever it asks you to run on installation. Making configurations, make sure it creates a unix socket at /run/mysqld/mysqld.sock and user running pica has permissions to write to this socket! By default it does, so, you're probably okay with default configuration.

Next you need to login to mariadb database server, usually it's done like so:

$ mariadb -u root -p

It will query your password, and then you should see mariadb propt. There you need to execute following commands:

CREATE DATABASE pica;
CREATE USER 'pica'@'localhost' IDENTIFIED BY 'pica';
GRANT ALL PRIVILEGES ON pica.* TO 'pica'@'localhost';
FLUSH PRIVILEGES;

Flushing privileges is not really needed, but it's typicaly written. After that just quit mariadb with quit; command.

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