Status of server project?
Hi,
I tried building the server using the feature/pika branch but ran into some issues as the it appears to a bit Windows-centric, is that intended?
I'd be happy to provide a few patches to improve compliation on FreeBSD 13.1 and most likely other UNIX based operating systems if that's of interest.
Edit: Unfortunately pika core dumps instantly if you add any kind of switch like -h or -v but starts without
Best regards, Daniel
Hi!
I don't think I've ever tried building the feature/pika branch on Windows, so I don't think you can call it Windows-centric 😄 I'm on Ubuntu and doing all development on that.
If all you want to do is run Pika, there are Docker images published for each push to the feature/pika branch, you can find the latest here - https://github.com/picotorrent/server/pkgs/container/pika. Building locally shouldn't be a problem either - it's mostly
git submodule update --init --recursive
mkdir build && cd build
cmake ..
cmake --build .
I'm still debating whether to include a web UI in the base container or not - right now the web UI is in a separate repo and Docker container and you'd need something like docker-compose to orchestrate it all. Here is my docker-compose setup for a seedbox I run,
version: '3.8'
services:
app:
image: ghcr.io/picotorrent/pika:0.2.4-pullrequest0016.48
labels:
- "traefik.enable=true"
- "traefik.http.routers.app.entrypoints=web"
- "traefik.http.routers.app.rule=PathPrefix(`/api`)"
- "traefik.http.services.app.loadbalancer.server.port=1337"
restart: unless-stopped
environment:
PIKA_CONFIG: |
db = "/data/pika.db"
[http]
addr = "0.0.0.0"
user: "1000:1000"
volumes:
- "./data:/data"
- "/mnt/media:/media"
web:
image: ghcr.io/picotorrent/pika-web:0.1.12
labels:
- "traefik.enable=true"
- "traefik.http.routers.web.entrypoints=web"
- "traefik.http.routers.web.rule=PathPrefix(`/`)"
restart: unless-stopped
traefik:
image: traefik:v2.6
command:
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:1337"
restart: unless-stopped
ports:
- "1337:1337"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
Using that, you should be able to access Pika on port 1337. The setup process will be smoother once I finish up everything and create proper documentation, etc 😄
Ahh, I made the Windows-centric assumption based on https://vcpkg.readthedocs.io/en/latest/about/faq/#which-platforms-i-can-target-with-vcpkg
Software:
OS: FreeBSD 13.1
Boost: 1.79.0
GoogleTest (aka gtest): 1.12.1
JSON (nlohmann_json): 3.10.5
Libtorrent: 2.0.6"+" (commit 34c75eb5f3e68896532838b9d408ccdc11b900ef in upstream repo)
LLVM/Clang 13.0.0
OpenSSL: 1.1.1o
SQLite: 3.38.5
toml++: 3.1.0
What I did:
- Disable vcpkg
- SQLite by default doesn't chip with .cmake files so rely on pkgconfig instead
- Add -DBOOST_LOG_DYN_LINK=1 otherwise pika wont link
- Disable tests (see log below)
Patch: https://projects.pyret.net/files/public/pika-cmakelists.txt
Fail log for tests (doesn't seem happy about GoogleTest): https://projects.pyret.net/files/public/pika-tests-error.log
Unfortunately FreeBSD doesn't support docker so unless I spin up a VM that's no go :-/
Now I need to figure out how npm works and build the web stuff... ;-)
Yeha the GoogleTest project doesn't run on Linux either - it hasn't been updated since the latest refactoring. It's on the todo list 😄
I'm not super familiar with FreeBSD but I'm happy to try and spin up a VM and make sure to support BSD builds. I'll see if I can add it to the CI as well! Awesome stuff with the patch, that helps alot.
For the npm stuff, it's a part of Node.js so if you get that installed you should be able to run
npm i
npm run build
And get a build/ directory with static HTML, CSS and JS which you can serve however.
Ahh, that made things much clearer :-)
It's pretty simple but toml++ is missing from the repo right now (I have a port ready), I'll write up something later today.
I'm running into an issue though, ENV seems to be completely ignored (and I can't find any references in the code so I guess the documentation needs some love) and I'm struggling a bit with the Web UI. It builds fine but it refers to the server incorrectly.
Accessing port 1337 Results in The resource '/' was not found and I can't tell where pika expects webroot. Hosting the Web UI using a http results in API requests pointing to the httpd's port not 1337 such as http://172.19.192.188:9999/api/events
The web UI and Pika itself is quite decoupled... You need to run Pika on any port, say 1337. Then run nginx (or similar) that hosts the static files as you did. You need to setup a reverse proxy from the /api route to the port Pika is using (1337 by default).
Something like this (for nginx):
location /api {
proxy_pass http://localhost:1337;
}
This will make the web UI requests route correctly.
Sorry it's a bit hacky right now 😅
Ahh, no worries :-)
Here's a very basic tutorial for a VM, once we have dependencies in tree it'll be much faster (and suitable for a CI as you can just install binary packages).
- Install FreeBSD 13.1
- Install git -->
pkg install git(as root, also applies to the rest below) - Grab the ports tree -->
git clone https://git.FreeBSD.org/ports.git /usr/ports - Fetch patches for dependencies and pika which are not not yet in tree
fetch https://projects.pyret.net/files/public/freebsd/tomlplusplus-new-port-v2.patch fetch https://projects.pyret.net/files/public/freebsd/libtorrent-rasterbar-20.patch fetch https://projects.pyret.net/files/public/freebsd/pika-port-wip.patch - Apply patches to /usr/ports
- Put the following in /etc/make.conf to save some time (optional):
OPTIONS_UNSET=DOCS EXAMPLES FLANG NLS TEST(this will also disable building of documentation) - Remove all pre-compiled packages to avoid mismatches -->
pkg delete -a -f - Install git -->
cd /usr/ports/devel/git && make BATCH=YES install clean clean-depends - Build libtorrent v2 -->
cd /usr/ports/net-p2p/libtorrent-rasterbar20 && make BATCH=YES install clean clean-depends - Build all dependencies for pika -->
cd /usr/ports/net-p2p/pika && make BATCH=YES depends clean-depends
Main port of libtorrent got reverted to 1.x due memory issues which also affects several other platforms hence the separate port
If you want npm --> cd /usr/ports/www/npm && make BATCH=YES depends clean-depends