pyroscope / pyrocore

:wrench: A collection of tools for the BitTorrent protocol and especially the rTorrent client
https://pyrocore.readthedocs.org/
GNU General Public License v2.0
291 stars 43 forks source link

How to integrate this into a docker rtorrent environment #81

Closed cactushydrocodone closed 4 years ago

cactushydrocodone commented 5 years ago

Hello,

I want to add this to my rtorrent/rutorrent container image. Now im trying around a bit and what is mostly stopping me is the "update-to-head.sh" script, as its always trying to write to /home/rtorrent instead of the directory i provide with the PYRO_CONFIG_DIR ENV variable. Even when i specify it explicitly, it gets ignored.

This is a bit annoying, is there an already made approach?

Do you have any idea what i could do? My current approach is more a workaround than something else...

pyroscope commented 5 years ago

The script writes where you place it. If you do things like docker, you're supoposed to be able to read bash. besides the full dockerfile in the rt-ps repo,

cactushydrocodone commented 5 years ago

Hmm. Weird. Maybe i need glasses, but those Commands... idk: grafik grafik They seem pretty static to me. Weird. :/

Esspecially this part tho grafik Do you see the userhome there? I do not lol

kannibalox commented 5 years ago

Here's a stupidly simple Dockerfile that I use:

FROM python:3

RUN mkdir /app

WORKDIR /app

COPY pyroscope .

RUN pip install -r requirements.txt

The requirements.txt in question (because I'm a selfish sucker for py3's string/bytes handling):

https://github.com/kannibalox/pyrobase/archive/py3.tar.gz
https://github.com/kannibalox/pyrocore/archive/py3.tar.gz
requests
APScheduler>=2.0.2,<3
Tempita>=0.5.1

Then I mount the configuration in kubernetes as so:

kind: ConfigMap
apiVersion: v1
metadata:
  name: pyrocore-config
  namespace: rtorrent
data:
  config.ini: |
    [GLOBAL]
    rtorrent_rc = /etc/rtorrent/rtorrent.rc
    [CONNECTIONS]
    local = scgi:///home/rtorrent/rtorrent/socket
  config.py: ""
  torque.ini: |
    [TORQUE]
    apscheduler.threadpool.core_threads     = 1
    apscheduler.threadpool.max_threads      = 1
    apscheduler.threadpool.keepalive        = 20
    apscheduler.misfire_grace_time          = 7
    apscheduler.coalesce                    = True
    job.exporter.handler           = pyroextra.rtorrent_exporter:RtorrentExporter
    job.exporter.jobs              = system,tracker
    # The schedule has no effect here
    job.exporter.schedule          = hour=*
    job.exporter.port              = 8000
    job.exporter.prefix            = rtorrent_
    job.exporter.active            = True
    job.exporter.dry_run           = False
    job.exporter.quiet             = False

Pod spec:

....
        volumeMounts:
        - name: pyrocore-config
          mountPath: /root/.pyroscope
....
      volumes:
        - name: pyrocore-config
          configMap:
            name: pyrocore-config
....

Obviously this needs plenty of work (not running as root would be the first step), but hopefully it helps you get started

pyroscope commented 4 years ago

${foo:-default} is a syntax found in man bash. In a Dockerfile, you need to explicitly set HOME because there is no bashrc etc that sets it. You need to understand those tools to be successful.