Running headless
njMule does not need a window. Its engine runs headless on a server, a NAS, a Raspberry Pi or a computer nobody sits at, and you drive it from a browser through its web interface, from the command line through its remote-control API, or from the desktop app of another computer. The headless engine is the same program as the desktop app's, with the same settings, files and network behaviour.
Start it
Every package has the njmule command, which runs the engine headless until you stop it:
- Windows
- macOS
- Linux
njmule
The installer puts njmule.exe on your PATH; from the zip archive, run it from its folder. It is
a console program: closing its window stops njMule (it saves first). To run njMule without anyone
signed in, make it a Windows service.
/Applications/njMule.app/Contents/MacOS/njmule
njmule
The deb and rpm packages install it in /usr/bin. The .tar.xz archive has it at its top, and the
static headless archive (njmule-<version>-linux-x64-static.tar.xz) holds nothing else: it needs no
library of the system and runs on any x64 Linux, Alpine or an old distribution included. To start
njMule at login, or keep it running after you log out, use the
systemd user unit.
The desktop app's window, njmule-gui, starts this same program for itself; on its own, njmule
needs no window and no desktop. At start njMule prints its notice, then where its configuration and
logs are and, when the web interface is on, its port; then it logs what happens until it stops.
Before the first headless start, give the web interface a password, or you will have no way to look at what njMule does:
njmule --webui-password --webui-lan # asks for the password twice, then exits
njmule # runs, with the web interface on port 4711
See Web interface for the options, and
Web interface security before you turn on --webui-lan.
Where it keeps its data
The headless engine uses the same folders as the desktop app on the same account: what one
downloads, the other sees. The defaults follow each system's conventions (Linux: ~/.config/njmule,
~/.local/share/njmule, ~/.local/state/njmule/logs, completed downloads in ~/Downloads/njMule);
Where njMule keeps its files lists them all.
-
--config-dir <dir>keeps everything below one folder instead (config,data,temp,cache,logs,guiandincoming), to run a separate profile or to keep a server's data in one place:njmule --config-dir /srv/njmule -
A
portable.flagfile beside the programs of an archive does the same with adatafolder next to them (Portable mode).
Only one njMule runs on one configuration at a time. A second headless start on the same
configuration hands its links to the running one, or fails with
njMule is already running with the configuration in … when it has none. A desktop app started
meanwhile hands its links to it as well and says njMule already runs without a window on this
profile instead of opening its window
(The window does not open). Give one of them
--config-dir if you want both at once, or drive the headless one instead.
Typical set-ups
| Where | How | Page |
|---|---|---|
| Docker, any Linux server or NAS | The image ghcr.io/njmule/njmule: the headless engine and its web interface, data in a volume | Docker |
| Synology DSM 7 | The .spk package, started and stopped by the Package Center | Synology |
| Windows | The service "njMule", started with Windows before anyone signs in | Windows service |
| Linux desktop or server | The systemd user unit of the deb and rpm packages | Linux service |
| Anywhere, by hand | njmule in a terminal, tmux or screen | this page |
Drive it
- From a browser: the web interface has every place of the desktop app.
- From the command line: with the API turned on,
njmule --remote status,njmule --remote add "ed2k://|file|…|/"and the other remote commands. - From another computer's desktop app: ⋯ → Connect to a remote njMule shows the headless njMule in a window of its own (Remote njMule).
- With links:
njmule "ed2k://|file|…|/"hands the links to the njMule running on the same configuration, which downloads them.
Stop it
njMule saves its downloads, lists and settings before it exits, which takes a few seconds. Any of these stops it cleanly:
- Ctrl+C in its terminal, or the
SIGTERMsignal ofkill,docker stopor systemd; njmule --exitfrom another terminal on the same computer and configuration (add--config-dirif it runs with one). It waits until njMule has saved and stopped, 30 seconds at most, and fails when no njMule runs there or when it still runs after that time;njmule --remote shutdown, here or with--remote-urlfrom another computer;- the stop of its supervisor: the Package Center,
njmule --service=stop,systemctl --user stop njmule.
Give a supervisor the time to save: Docker's --stop-timeout 30, Compose's
stop_grace_period: 30s.
Logs
The headless engine logs to its console (standard output) and to njmule.log in the logs folder,
which turns over every day and at 10 MB, and keeps 14 days and 200 MB at most. Under Docker,
docker logs njmule shows the console; under systemd, journalctl --user -u njmule.
- The level is
INFOunlesslog.levelinnjmule.propertiessays otherwise;--log-level DEBUGoverrides it for one run (ERROR,WARN,INFO,DEBUGorTRACE). - The web interface shows the latest lines under Network → Log, and
njmule --remote logprints them.
Logs tells more about the files and what they hold.
Related pages
- Command line: every option of
njmule. - Remote control: the commands and the API.
- Web interface
- Updates: how a headless njMule is updated.