xmrig icon indicating copy to clipboard operation
xmrig copied to clipboard

Logs not works anymore

Open SnAFKe opened this issue 1 year ago • 12 comments

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

  • XMRig version
    • 6.21.3-mo15
  • OS: Linux x64

SnAFKe avatar Jun 02 '24 10:06 SnAFKe

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.

Spudz76 avatar Jun 02 '24 13:06 Spudz76

you can also use a systemctl service to track logs

ghost avatar Jun 02 '24 14:06 ghost

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.

SnAFKe avatar Jun 02 '24 17:06 SnAFKe

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.

Spudz76 avatar Jun 02 '24 17:06 Spudz76

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.

SnAFKe avatar Jun 02 '24 18:06 SnAFKe

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

Spudz76 avatar Jun 02 '24 18:06 Spudz76

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.

SnAFKe avatar Jun 02 '24 19:06 SnAFKe

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 avatar Jun 02 '24 20:06 Spudz76

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 avatar Jun 02 '24 20:06 Spudz76

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

Spudz76 avatar Jun 02 '24 20:06 Spudz76

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.

SnAFKe avatar Jun 03 '24 00:06 SnAFKe

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

Spudz76 avatar Jun 04 '24 21:06 Spudz76