tribler icon indicating copy to clipboard operation
tribler copied to clipboard

Tribler command line mode

Open xoriole opened this issue 7 years ago • 15 comments

Tribler command line mode

To run Tribler in command line mode, following two options are provided:

1. # tribler --headless Tribler will run without GUI. The process id is listed in /tmp/tribler.pid file and console logs are written to /tmp/tribler.log file

2. # tribler --plugin <plugin_name> <plugin_arguments> --plugin argument loads and runs the plugin, also in head less mode. The default path for the console logs is /tmp/<plugin_name>.log , however it can also be passed as argument with --logfile argument.

for example, to run torrent_downloader plugin, a sample command could look like: # tribler --plugin torrent_downloader --magnetfile=<magnet_file> --limit=5 The above command downloads first 5 torrents (from magnet link) listed in the magnet file. The logs can be found at /tmp/torrent_downloader.log

Tribler plugins are basically twistd plugins but are located in Tribler/plugins instead of twisted/plugins directory. These plugins are not necessary to run Tribler but instead uses Tribler, so they are available in separate tribler-cli branch and not in next or devel.

xoriole avatar Nov 16 '17 09:11 xoriole

I noticed there is a sort of hacky headless option

/usr/bin/tribler -platform linuxfb
Starting Tribler...

Dmole avatar Mar 23 '18 17:03 Dmole

Is there any hacky way to run tribler headless on windows?

ghost avatar Apr 29 '18 12:04 ghost

@cranphin you could try to force kill the GUI process and leave the core running (I don't know if this actually works).

qstokkink avatar Apr 29 '18 12:04 qstokkink

I guess I did ask for a hacky way :) Yeah, looks like it leaves the child process running, good enough for me for now :)

ghost avatar Apr 29 '18 14:04 ghost

@cranphin the following should also work, based on: https://github.com/Tribler/tribler/blob/d5be6bab8ee456cde1c9bb3ab6056c5a1c3f7a92/run_tribler.py#L60-L63

Execute the following when launching Tribler:

SETLOCAL
SET CORE_PROCESS=1
SET CORE_BASE_PATH=%cd%
SET CORE_API_PORT=8085
tribler.exe

Disclaimer: you may have to tinker with this a bit to get it working. Also, you may need the latest build for this (this functionality was not in 7.0.2 yet).

qstokkink avatar Apr 29 '18 14:04 qstokkink

I have tried to open tribler as xeriole commented from command line, with the command: tribler --plugin torrent_downloader --torrentfile=<torrent_file> but the only thing it happens it's that tribler opens but the torrent_file is not added to the downloads queue. Furthermore, I have tried to open tribler whitout GUI by using tribler --headless but it starts tribler with GUI. I would like to install tribler in a raspberry pi and control it by command line using ssh. Anyone kwows if it is possible?

javiggvv avatar Sep 18 '19 17:09 javiggvv

You can start tribler than kill just the GUI with

/usr/bin/tribler >/dev/null 2>&1 &
sleep 10
kill "$(pgrep -f tribler | head -n 1)"

you can control it via the API;

curl -sX GET "http://localhost:8085/downloads" \
    | jq '.downloads[] | select( .progress | tostring | test("1") | not ) | .infohash'

Dmole avatar Sep 18 '19 17:09 Dmole

@javiggvv To run Tribler in headless mode, you can run the core process only. It will not invoke GUI. You can start the process like this:

env CORE_PROCESS=1 CORE_BASE_PATH=`pwd` CORE_API_PORT=8085 tribler

To add a torrent for downloading you'll have to use REST API for now.

tribler-cli branch and the plugins are quite outdated at the moment. I'll update them when I have more time.

xoriole avatar Sep 19 '19 07:09 xoriole

@javiggvv To run Tribler in headless mode, you can run the core process only. It will not invoke GUI. You can start the process like this:

env CORE_PROCESS=1 CORE_BASE_PATH=`pwd` CORE_API_PORT=8085 tribler

To add a torrent for downloading you'll have to use REST API for now.

tribler-cli branch and the plugins are quite outdated at the moment. I'll update them when I have more time.

I have tried it as you told me and it runs perfectly. Thank you very much!

javiggvv avatar Sep 19 '19 08:09 javiggvv

related: https://github.com/Tribler/tribler/issues/5327

hbiyik avatar May 24 '20 14:05 hbiyik

I can't run tribler 7.10 headless:

$ CORE_PROCESS=1 CORE_BASE_PATH=`pwd` CORE_API_PORT=8085 tribler
INFO:__main__:Sentry has been initialised in normal mode
INFO:__main__:Root state dir: /home/p2p/.Tribler
INFO:__main__:Running in "core" mode
INFO:tribler_core.dependencies:Check for missing dependencies. Scope: core
INFO:SentryReporter:Before send strategy: SentryStrategy.SEND_ALLOWED_WITH_CONFIRMATION
qt.qpa.xcb: could not connect to display 
qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in "/nix/store/4fqm953fv5y6kzb45h6pzrwqq9cv97fi-qtbase-5.15.3-bin/lib/qt-5.15.3/plugins/platforms"
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs (from /nix/store/4fqm953fv5y6kzb45h6pzrwqq9cv97fi-qtbase-5.15.3-bin/lib/qt-5.15.3/plugins/platforms), linuxfb (from /nix/store/4fqm953fv5y6kzb45h6pzrwqq9cv97fi-qtbase-5.15.3-bin/lib/qt-5.15.3/plugins/platforms), minimal (from /nix/store/4fqm953fv5y6kzb45h6pzrwqq9cv97fi-qtbase-5.15.3-bin/lib/qt-5.15.3/plugins/platforms), minimalegl (from /nix/store/4fqm953fv5y6kzb45h6pzrwqq9cv97fi-qtbase-5.15.3-bin/lib/qt-5.15.3/plugins/platforms), offscreen (from /nix/store/4fqm953fv5y6kzb45h6pzrwqq9cv97fi-qtbase-5.15.3-bin/lib/qt-5.15.3/plugins/platforms), vnc (from /nix/store/4fqm953fv5y6kzb45h6pzrwqq9cv97fi-qtbase-5.15.3-bin/lib/qt-5.15.3/plugins/platforms), xcb (from /nix/store/4fqm953fv5y6kzb45h6pzrwqq9cv97fi-qtbase-5.15.3-bin/lib/qt-5.15.3/plugins/platforms).

Aborted (s'ha bolcat la memòria)

viric avatar Dec 30 '21 15:12 viric

@viric we have just released Tribler 7.11, which you can download from here. In Tribler 7.11, we improved headless support for Tribler. You should be able to run the Tribler core with the following command:

CORE_API_PORT=8085 ./tribler.sh --core

Where the CORE_API_PORT environment variable specifies the listen port of the HTTP API. Could you let us know if that works for you?

devos50 avatar Jan 03 '22 09:01 devos50

@devos50 I tried to start headless Tribler 7.11 (it is running on Ubuntu desktop 20.04.3) with this string: CORE_API_PORT=52194 ./tribler.sh --core -bash: ./tribler.sh: No such file or directory I tried to find it in other locations but didn't find it as well. So I tried the: CORE_API_PORT=52194 /bin/tribler --core The result was: Starting Tribler... /usr/share/tribler ~ Aborted (core dumped)

t410s avatar Jan 10 '22 15:01 t410s

@t410s thanks for your report. Are you able to run Tribler normally, without the --core flag and the CORE_API_PORT env variable?

devos50 avatar Jan 14 '22 10:01 devos50

@devos50 Yes I am able to run Tribler normally.

t410s avatar Jan 14 '22 13:01 t410s