MoneroOcean / xmrig

Monero (rx/0, rx/wow, rx/loki, defyx, rx/arq, rx/sfx, rx/keva, cn/0, cn/1, cn/2, cn/r, cn/fast, cn/half, cn/xao, cn/rto, cn/rwz, cn/zls, cn/double, cn/gpu, cn-lite/0, cn-lite/1, cn-heavy/0, cn-heavy/tube, cn-heavy/xhv, cn-pico, cn-pico/tlo, argon2/chukwa, argon2/wrkz, astrobwt) CPU/GPU miner
https://moneroocean.stream
GNU General Public License v3.0
273 stars 84 forks source link

Logs not works anymore #145

Open SnAFKe opened 3 months ago

SnAFKe commented 3 months ago

Describe the bug Logs not working if you setup as background mode

To Reproduce Run xmrig as backgroud with log file setup

Expected behavior It should run just fine.

Required data

Spudz76 commented 3 months ago

I just tested it and it works fine.

Ensure permissions where the log file is, directory may not have write permissions to user running xmrig. Or, "touch" the file and set wide open permissions on it so xmrig can append.

realsetvin commented 3 months ago

you can also use a systemctl service to track logs

SnAFKe commented 3 months ago

I just tested it and it works fine.

Ensure permissions where the log file is, directory may not have write permissions to user running xmrig. Or, "touch" the file and set wide open permissions on it so xmrig can append.

Already done before and working fine is not permision issue or whatever.

Other report same issue i had https://github.com/xmrig/xmrig/issues/3455

you can also use a systemctl service to track logs

Already do that and i don't like journal.

Spudz76 commented 3 months ago

Ahh, the actual --background option. There are myriad ways to run a thing in the background (screen, systemd, nohup...) so I didn't connect that it was the literal built-in option (which I have never once used so its existence was not at top of mind).

I will look into that.

SnAFKe commented 3 months ago

I'm not sure if you understand my issue.

I had already systemd script which point to config file and config file i set background and log-file option.

Other guy have same issue as me, he do it in command line which is currently the same.

Spudz76 commented 3 months ago

What is the point of using --background when a systemd service is already in the background?

SnAFKe commented 3 months ago

I never able to run xmrig in background with systemd and the only option i can do this is with --background.

Also what i say before, logs i don't like logs in the journal i perfer use log file.

Spudz76 commented 3 months ago

Then make an appropriate service file (/lib/systemd/system/xmrig.service):

[Unit]
Description=xmrig
After=network-online.target systemd-modules-load.service
Wants=network-online.target systemd-modules-load.service
AssertFileNotEmpty=/opt/xmrig/config.json

[Service]
Type=simple
User=root
Group=root
Restart=always
KillSignal=SIGINT
LimitMEMLOCK=8G
WorkingDirectory=/opt/xmrig
StandardOutput=null
StandardError=null
SyslogIdentifier=xmrig
TimeoutStartSec=30s
TimeoutStopSec=15s
ExecStart=/opt/xmrig/xmrig

[Install]
WantedBy=multi-user.target

When the StandardOutput and StandardErrror are set null it will just throw away any output and not journal it.

This runs xmrig in the background just fine without using xmrig --background option ("background": false, in config.json), and log-file will work.

Spudz76 commented 3 months ago

Also I traced all the xmrig code and log messages are sent to uv_fs_write just like they are when it's not forked to background, so the bug must be within libuv somehow. Above my paygrade.

Spudz76 commented 3 months ago

Oh also this is an issue upstream so complain there or bump the issue you linked. It's not a MoneroOcean bug.

Commit that probably broke it: https://github.com/xmrig/xmrig/commit/688d4f5ee16fab4d7153c0c92005925b4dd0f008

SnAFKe commented 3 months ago

Looking for more deep because was working fine before i finally see where is come this "problem"

This is the last build working fine v6.21.1-mo1/v6.21.1. Start build v6.21.2-mo1/v6.21.2 is where come the issue, the commit you link was in v6.21.3 may or may not be related, but what i can see is started in v6.21.2.

Spudz76 commented 3 months ago

Has been fixed in upstream dev branch, will be in next upstream master release (whenever that is).