Closed lexo-mfleuti closed 1 year ago
uv_guess_handle returned 17
is UV_FILE
- you probably created /tmp/p2pool.stdin
not as a FIFO, but as a regular file.
You need remove Type=simple but lead to another error if you have enable logs will flood you unlimited and create in about 6gb per minute.
Can you check SChernykh this when log is enable? give me this error
WARNING 2023-04-18 21:15:47.6701 ConsoleCommands Unknown command 2023-04-18 21:15:47.6700
WARNING 2023-04-18 21:15:47.6701 ConsoleCommands Unknown command 2023-04-18 21:15:47.6701
WARNING 2023-04-18 21:15:47.6701 ConsoleCommands Unknown command 2023-04-18 21:15:44.9665 Log started
WARNING 2023-04-18 21:15:47.6701 ConsoleCommands Unknown command 2023-04-18 21:15:44.9692 P2Pool v3.2 (built with GCC/10.2.1 on Apr 12 2023)
WARNING 2023-04-18 21:15:47.6701 ConsoleCommands Unknown command 2023-04-18 21:15:44.9703 SideChain network type = mainnet
WARNING 2023-04-18 21:15:47.6701 ConsoleCommands Unknown command 2023-04-18 21:15:44.9705 SideChain using default config
WARNING 2023-04-18 21:15:47.6702 ConsoleCommands Unknown command 2023-04-18 21:15:44.9707 SideChain pool name = default
WARNING 2023-04-18 21:15:47.6702 ConsoleCommands Unknown command 2023-04-18 21:15:44.9707 SideChain block time = 10 seconds
WARNING 2023-04-18 21:15:47.6702 ConsoleCommands Unknown command 2023-04-18 21:15:44.9707 SideChain min diff = 100000
WARNING 2023-04-18 21:15:47.6702 ConsoleCommands Unknown command 2023-04-18 21:15:44.9707 SideChain PPLNS window = 2160 blocks
WARNING 2023-04-18 21:15:47.6702 ConsoleCommands Unknown command 2023-04-18 21:15:44.9707 SideChain uncle penalty = 20%
......
......
WARNING 2023-04-18 21:15:47.6702 ConsoleCommands Unknown command 2023-04-18 21:15:45.1936 ConsoleCommands uv_guess_handle returned 7
WARNING 2023-04-18 21:15:47.6702 ConsoleCommands Unknown command 2023-04-18 21:15:45.1936 ConsoleCommands processing stdin as UV_NAMED_PIPE
WARNING 2023-04-18 21:15:47.6702 ConsoleCommands Unknown command 2023-04-18 21:15:45.1937 ConsoleCommands event loop started
WARNING 2023-04-18 21:15:47.6702 ConsoleCommands Unknown command ---------------------------------------------------------------------------------------------------------------
WARNING 2023-04-18 21:15:47.6703 ConsoleCommands Unknown command median_weight = 300000
uv_guess_handle returned 17
isUV_FILE
- you probably created/tmp/p2pool.stdin
not as a FIFO, but as a regular file.
Thank you very much @SChernykh for your very quick reply. It's actually a FIFO file. As a test I recreated it in /opt/p2pool.fifo and changed the service to auto-create the file if it does not exist:
p2pool.service
[Unit]
Description=P2Pool Full Node
After=network.target p2pool.socket
Requires=monerod.service
BindsTo=p2pool.socket
[Service]
WorkingDirectory=/opt/p2pool/build/
Type=simple
Restart=always
ExecStartPre=/bin/bash -c '[[ -p /opt/p2pool.fifo ]] || mkfifo /opt/p2pool.fifo; exit 0'
ExecStartPre=sysctl vm.nr_hugepages=3072
ExecStart=/opt/p2pool/build/p2pool --loglevel 4 --host 127.0.0.1 --wallet ABCD
[Install]
WantedBy=multi-user.target
Still, same error :(
NOTICE 2023-04-19 17:30:06.7174 ConsoleCommands listening on 127.0.0.1:54623
NOTICE 2023-04-19 17:30:06.7177 ConsoleCommands uv_guess_handle returned 17
ERROR 2023-04-19 17:30:06.7177 ConsoleCommands tty or named pipe is not available
NOTICE 2023-04-19 17:30:06.7177 ConsoleCommands event loop started
ERROR 2023-04-19 17:30:06.7177 ConsoleCommands TCP wasn't shutdown properly
Since I could not find any documentation I have no clue what else I could try to make P2Pool work with a socket. I'd prefer the socket solution to be also able to send commands to the service. But I don't know what else to do. Is there some manual somewhere that i could follow about that maybe?
Well, https://github.com/SChernykh/p2pool/issues/237 has ListenFIFO
instead of ListenStream
in your config.
Thank you. Sorry for the confusion. I did set it to ListenFIFO
and that did not work and then I checked some configs and thus tried ListenStream
instead. I am getting the very same error when setting ListenFIFO
:
NOTICE 2023-04-19 17:59:01.9627 ConsoleCommands listening on 127.0.0.1:57904
NOTICE 2023-04-19 17:59:01.9630 ConsoleCommands uv_guess_handle returned 17
ERROR 2023-04-19 17:59:01.9630 ConsoleCommands tty or named pipe is not available
NOTICE 2023-04-19 17:59:01.9630 ConsoleCommands event loop started
ERROR 2023-04-19 17:59:01.9631 ConsoleCommands TCP wasn't shutdown properly
It would also be OK for me, if there was a parameter to make P2Pool work like it was before (2 days ago). Currently it just only works on console and I cannot run it in the background as a service.
Or perhaps I do need to start P2Pool with some additional parameter which I don't know about to make it work with the FIFO socket?
What was the latest commit that works with your current config?
This one: https://github.com/SChernykh/p2pool/tree/80352f6b303e210c902d38487dceb2dda7fce4ed I skipped the one from 17.04.2023 and updated today again. Ever since it's not working anymore.
Can you try to build from that commit again to confirm it's not something with your system?
With this commit it works: https://github.com/SChernykh/p2pool/tree/ce192670a3620fdad376c5a24cb9ec8df7b33ca1 With this it starts to break: https://github.com/SChernykh/p2pool/tree/196b27f3b21bcf8096ecee1e3b7d089ded1fa30f
Can you try the latest commit? I don't know why it broke, the functionality in ce192670a3620fdad376c5a24cb9ec8df7b33ca1 shouldn't interfere.
OK, with this latest commit it works again: 7a83fd2f30762df502331b2c99bcf69a9662fa43
With the socket function enabled, I am getting now millions of log entries like this though:
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands List of commands
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands help display list of commands
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands status display p2pool status
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands loglevel <level> set log level
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands addpeers <peeraddr> add peer
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands droppeers disconnect all peers
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands peers show all peers
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands workers show all connected workers
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands bans show all banned IPs
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands outpeers <N> set maximum number of outgoing connections
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands inpeers <N> set maximum number of incoming connections
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands start_mining <threads> start mining
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands stop_mining stop mining
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands exit terminate p2pool
WARNING 2023-04-19 19:16:06.1996 ConsoleCommands Unknown command 2023-04-19 19:16:06.1947 ConsoleCommands Unknown command 2023-04-19 19:16:06.1927 ConsoleCommands stop_mining stop mining
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands List of commands
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands help display list of commands
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands status display p2pool status
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands loglevel <level> set log level
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands addpeers <peeraddr> add peer
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands droppeers disconnect all peers
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands peers show all peers
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands workers show all connected workers
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands bans show all banned IPs
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands outpeers <N> set maximum number of outgoing connections
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands inpeers <N> set maximum number of incoming connections
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands start_mining <threads> start mining
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands stop_mining stop mining
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands exit terminate p2pool
WARNING 2023-04-19 19:16:06.1996 ConsoleCommands Unknown command 2023-04-19 19:16:06.1948 ConsoleCommands Unknown command 2023-04-19 19:16:06.1927 ConsoleCommands exit terminate p2pool
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands List of commands
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands help display list of commands
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands status display p2pool status
NOTICE 2023-04-19 19:16:06.1996 ConsoleCommands loglevel <level> set log level
Update: After a while it seems to crash now. Trying without FIFO now:
NOTICE 2023-04-19 19:16:18.2155 TCPServer stopped
NOTICE 2023-04-19 19:16:18.2155 P2Pool uv_run exited, result = 0
NOTICE 2023-04-19 19:16:18.2155 ZMQReader stopping
NOTICE 2023-04-19 19:16:18.2156 ZMQReader worker thread stopped
NOTICE 2023-04-19 19:16:18.2163 Util waiting for 1 "P2PServer::handle_incoming_block_async" jobs to finish
NOTICE 2023-04-19 19:16:18.2180 SideChain add_block: height = 4930725, id = e030c54126ff5929809eb23d478cf6a7261b4cab007e909bdb02ee6d49e2055d, mainchain height = 2867691, verified = 0
NOTICE 2023-04-19 19:16:18.2202 SideChain add_block: height = 4930724, id = c654ebae6ae9da0cd0d9b254eb01d6dec6fa745c5bf70905b47a6812a8cbac39, mainchain height = 2867691, verified = 0
NOTICE 2023-04-19 19:16:18.2223 SideChain add_block: height = 4930723, id = 64f33e6ce18700b67489d75039606e4118e1047e6622002f9eef925d92856a44, mainchain height = 2867691, verified = 0
WARNING 2023-04-19 19:16:18.2230 StratumServer closed 43 active client connections
NOTICE 2023-04-19 19:16:18.2231 StratumServer event loop stopped
NOTICE 2023-04-19 19:16:18.2238 TCPServer stopped
WARNING 2023-04-19 19:16:18.2240 P2PServer closed 9 active client connections
NOTICE 2023-04-19 19:16:18.2264 SideChain add_block: height = 4930722, id = 415beffb637f7842f91c4ca845fad85643b87b1ef8d53446323539207ce858a1, mainchain height = 2867691, verified = 0
NOTICE 2023-04-19 19:16:19.2247 P2PServer waiting for event loop to stop for 29 more seconds (14 handles left)...
NOTICE 2023-04-19 19:16:20.2257 P2PServer waiting for event loop to stop for 28 more seconds (14 handles left)...
NOTICE 2023-04-19 19:16:21.2266 P2PServer waiting for event loop to stop for 27 more seconds (14 handles left)...
NOTICE 2023-04-19 19:16:22.2276 P2PServer waiting for event loop to stop for 26 more seconds (14 handles left)...
NOTICE 2023-04-19 19:16:23.2278 P2PServer waiting for event loop to stop for 25 more seconds (14 handles left)...
NOTICE 2023-04-19 19:16:24.2281 P2PServer waiting for event loop to stop for 24 more seconds (14 handles left)...
NOTICE 2023-04-19 19:16:25.2291 P2PServer waiting for event loop to stop for 23 more seconds (14 handles left)...
NOTICE 2023-04-19 19:16:26.2302 P2PServer waiting for event loop to stop for 22 more seconds (14 handles left)...
NOTICE 2023-04-19 19:16:27.2313 P2PServer waiting for event loop to stop for 21 more seconds (14 handles left)...
NOTICE 2023-04-19 19:16:28.2324 P2PServer waiting for event loop to stop for 20 more seconds (14 handles left)...
NOTICE 2023-04-19 19:16:29.2336 P2PServer waiting for event loop to stop for 19 more seconds (14 handles left)...
NOTICE 2023-04-19 19:16:30.2347 P2PServer waiting for event loop to stop for 18 more seconds (14 handles left)...
NOTICE 2023-04-19 19:16:31.2358 P2PServer waiting for event loop to stop for 17 more seconds (14 handles left)...
NOTICE 2023-04-19 19:16:32.2370 P2PServer waiting for event loop to stop for 16 more seconds (14 handles left)...
NOTICE 2023-04-19 19:16:33.2381 P2PServer waiting for event loop to stop for 15 more seconds (14 handles left)...
NOTICE 2023-04-19 19:16:34.2391 P2PServer waiting for event loop to stop for 14 more seconds (14 handles left)...
NOTICE 2023-04-19 19:16:35.2401 P2PServer waiting for event loop to stop for 13 more seconds (14 handles left)...
NOTICE 2023-04-19 19:16:36.2412 P2PServer waiting for event loop to stop for 12 more seconds (14 handles left)...
NOTICE 2023-04-19 19:16:37.2423 P2PServer waiting for event loop to stop for 11 more seconds (14 handles left)...
NOTICE 2023-04-19 19:16:38.2434 P2PServer waiting for event loop to stop for 10 more seconds (14 handles left)...
NOTICE 2023-04-19 19:16:39.2446 P2PServer waiting for event loop to stop for 9 more seconds (14 handles left)...
NOTICE 2023-04-19 19:16:40.2456 P2PServer waiting for event loop to stop for 8 more seconds (14 handles left)...
NOTICE 2023-04-19 19:16:41.2466 P2PServer waiting for event loop to stop for 7 more seconds (14 handles left)...
NOTICE 2023-04-19 19:16:42.2477 P2PServer waiting for event loop to stop for 6 more seconds (14 handles left)...
NOTICE 2023-04-19 19:16:43.2480 P2PServer waiting for event loop to stop for 5 more seconds (14 handles left)...
NOTICE 2023-04-19 19:16:44.2491 P2PServer waiting for event loop to stop for 4 more seconds (14 handles left)...
NOTICE 2023-04-19 19:16:45.2501 P2PServer waiting for event loop to stop for 3 more seconds (14 handles left)...
NOTICE 2023-04-19 19:16:46.2512 P2PServer waiting for event loop to stop for 2 more seconds (14 handles left)...
NOTICE 2023-04-19 19:16:47.2521 P2PServer waiting for event loop to stop for 1 more seconds (14 handles left)...
NOTICE 2023-04-19 19:16:48.2531 P2PServer force stopping the event loop...
WARNING 2023-04-19 19:16:48.2531 P2PServer uv_run returned 1
WARNING 2023-04-19 19:16:48.2531 P2PServer uv_loop_close returned error EBUSY
NOTICE 2023-04-19 19:16:48.2532 P2PServer event loop stopped
NOTICE 2023-04-19 19:16:48.2532 TCPServer stopped
NOTICE 2023-04-19 19:16:48.2648 P2Pool stopped
NOTICE 2023-04-19 19:16:48.2670 RandomX_Hasher stopped
NOTICE 2023-04-19 19:16:48.2674 Log stopped
UPDATE: without FIFO settings enabled it works again as a service with the newest build (https://github.com/SChernykh/p2pool/tree/7a83fd2f30762df502331b2c99bcf69a9662fa43)
I cannot make FIFO work. But, it's not that important to me. Would be nice though.
I cannot make FIFO work. But, it's not that important to me. Would be nice though.
Something is still broken, because uv_guess_handle
returns UV_NAMED_PIPE
early at startup, but then it changes to UV_FILE
. So it's almost like something inside p2pool changes stdin handle from the original pipe to something else in the latest code.
I cannot reproduce uv_guess_handle returned 17
on an Ubuntu 20.04 VM with the latest code. ListenStream
works for me.
With the FIFO is the problem with millions of log entries in log file? because is the only issue i have with fifo, i can't start p2pool with log enabled.
Yes, this FIFO issue happens even with the older code. But ListenStream
works correctly.
Judging by the log, it gets into infinite loop where each line in p2pool console output gets interpreted as a command. Maybe this is how ListenFIFO works and ListenStream should be used instead.
Yes, this FIFO issue happens even with the older code. But
ListenStream
works correctly.
Maybe because of this? https://github.com/SChernykh/p2pool/pull/238
How ListenStream make to work? i not understand, when i do echo "status" > /tmp/p2pool.stdin
return me
/tmp/p2pool.stdin : No such device or address
Yes, I have the same issue. It must be ListenFIFO to work correctly, but something else is missing in service or socket configs. @twlee79 can you help?
I've built from source from commit 5f18eed and it seems to run fine as a service on my system, using a named pipe on Arch Linux, with the console control by writing to the named pipe (e.g. echo status
to get status written to log). The binaries for v3.2 work correctly as well.
The above issues appear to be related to the console being flooded by something writing to the pipe, or perhaps using an existing file as the pipe. The file should not already exist - the socket in charge of creating and destroying it. I have not tested other configuration options for running as a service with the current build.
My configuration (removing some lines that should be non-essential) is:
p2pool.socket
# FIFO socket for controlling p2pool daemon
[Unit]
Description=Command FIFO for p2pool daemon
[Socket]
ListenFIFO=/run/p2pool/p2pool.control
DirectoryMode=0755
SocketMode=0666
SocketUser=p2pool
SocketGroup=p2pool
RemoveOnStop=true
p2pool.service
[Unit]
Description=p2pool daemon
After=network-online.target systemd-modules-load.service monerod.service
Wants=network-online.target systemd-modules-load.service monerod.service
Requires=p2pool.socket
[Service]
Type=exec
Sockets=p2pool.socket
StandardInput=socket
StandardOutput=journal
StandardError=journal
ExecStart=/usr/local/bin/p2pool.sh
ExecStop=/usr/local/bin/p2pool_stop.sh
TimeoutStopSec=60
# Run as p2pool:p2pool
User=p2pool
Group=p2pool
WorkingDirectory=/var/lib/p2pool
[Install]
WantedBy=multi-user.target
/usr/local/bin/p2pool.sh
simply invokes the p2pool
executable with my chosen command-line options.
p2pool_stop.sh
writes exit
to the named pipe then waits for the process to terminate:
#!/bin/bash
#
# Script to exit p2pool
# Used by p2pool.service
# Issue exit command and then wait for process exit, or script timeout
echo "exit" > /run/p2pool/p2pool.control
while kill -0 "${MAINPID}" 2> /dev/null; do
sleep 1s
done
Edit: Sorry, copy/paste error in the original was missing the ExecStart=/usr/local/bin/p2pool.sh
line.
Can you share your p2pool.sh?
Not sure why complicate so much for to many configurations and bash script to run a simple service.
Anyways for me in the end always stuck with the same error with millions of log entries in log file not change anything.
The bash script has my wallet ID and RPC login credentials, so my logic of starting this using a script is to keep these parameters separate from the service config. There is no reason why you can't put these in the service config if that's what you prefer. Here it is:
p2pool.sh
#!/bin/bash
/usr/local/bin/p2pool/p2pool --wallet <redacted> --host <redacted> --rpc-port <redacted> --rpc-login <redacted> --zmq-port <redacted> --stratum <redacted>
As I said, it invokes the p2pool executable, nothing more.
The reason for using a bash script to stop the service is also clear from above; it issues exit
to the console to stop p2pool
, as per normal usage when operating from the CLI.
This flooding is because your log output is somehow being directed to your named pipe for stdin:
You need remove Type=simple but lead to another error if you have enable logs will flood you unlimited and create in about 6gb per minute.
Can you check SChernykh this when log is enable? give me this error
WARNING 2023-04-18 21:15:47.6701 ConsoleCommands Unknown command 2023-04-18 21:15:47.6700 WARNING 2023-04-18 21:15:47.6701 ConsoleCommands Unknown command 2023-04-18 21:15:47.6701 WARNING 2023-04-18 21:15:47.6701 ConsoleCommands Unknown command 2023-04-18 21:15:44.9665 Log started WARNING 2023-04-18 21:15:47.6701 ConsoleCommands Unknown command 2023-04-18 21:15:44.9692 P2Pool v3.2 (built with GCC/10.2.1 on Apr 12 2023) WARNING 2023-04-18 21:15:47.6701 ConsoleCommands Unknown command 2023-04-18 21:15:44.9703 SideChain network type = mainnet WARNING 2023-04-18 21:15:47.6701 ConsoleCommands Unknown command 2023-04-18 21:15:44.9705 SideChain using default config WARNING 2023-04-18 21:15:47.6702 ConsoleCommands Unknown command 2023-04-18 21:15:44.9707 SideChain pool name = default WARNING 2023-04-18 21:15:47.6702 ConsoleCommands Unknown command 2023-04-18 21:15:44.9707 SideChain block time = 10 seconds WARNING 2023-04-18 21:15:47.6702 ConsoleCommands Unknown command 2023-04-18 21:15:44.9707 SideChain min diff = 100000 WARNING 2023-04-18 21:15:47.6702 ConsoleCommands Unknown command 2023-04-18 21:15:44.9707 SideChain PPLNS window = 2160 blocks WARNING 2023-04-18 21:15:47.6702 ConsoleCommands Unknown command 2023-04-18 21:15:44.9707 SideChain uncle penalty = 20% ...... ...... WARNING 2023-04-18 21:15:47.6702 ConsoleCommands Unknown command 2023-04-18 21:15:45.1936 ConsoleCommands uv_guess_handle returned 7 WARNING 2023-04-18 21:15:47.6702 ConsoleCommands Unknown command 2023-04-18 21:15:45.1936 ConsoleCommands processing stdin as UV_NAMED_PIPE WARNING 2023-04-18 21:15:47.6702 ConsoleCommands Unknown command 2023-04-18 21:15:45.1937 ConsoleCommands event loop started WARNING 2023-04-18 21:15:47.6702 ConsoleCommands Unknown command --------------------------------------------------------------------------------------------------------------- WARNING 2023-04-18 21:15:47.6703 ConsoleCommands Unknown command median_weight = 300000
Are you sure you aren't directing the stdout to the named pipe in your configuration? Otherwise, there must be some bug somewhere doing this under certain circumstances. It definitely isn't occurring in my system.
#!/bin/bash /usr/local/bin/p2pool/p2pool --wallet <redacted> --host <redacted> --rpc-port <redacted> --rpc-login <redacted> --zmq-port <redacted> --stratum <redacted>
I guess, I already knew that you didn't have the logs enabled, that's why you didn't notice that important error
Are you sure you aren't directing the stdout to the named pipe in your configuration? Otherwise, there must be some bug somewhere doing this under certain circumstances. It definitely isn't occurring in my system.
I tested exactly with your config give me this error, also @SChernykh report same error so i think is not my fault.
What do you mean by "didn't have logs enabled"? Logs are enabled by default. The default loglevel is 3. My service configuration has stdout logs redirected to systemd journal. The p2pool.log
file is also produced in the working directory and I can issue commands to the console via the named pipe and read the log, such as: echo -e "status\nworkers" > /var/run/p2pool/p2pool.control; sleep 1; tail /var/lib/p2pool/p2pool.log -n 40
which shows me that status of p2pool.
To add, I believe the systemd default for StandardOutput
and StandardError
is inherit
, which inherits the file descriptor in StandardInput
, so it is essential that StandardOutput
and StandardError
are changed in the service config (e.g.
StandardOutput=journal
and StandardError=journal
as per my config).
The above configurations posted by other users do not have a setting for StandardOutput
and StandardError
in the service config, presumably defaulting to inherit
and causing the infinite loop where all output is redirected to the named pipe and interpreted as new console commands.
The above configurations posted by other users do not have a setting for StandardOutput and StandardError in the service config, presumably defaulting to inherit and causing the infinite loop where all output is redirected to the named pipe and interpreted as new console commands.
Yes, this is exactly what happened when I tested it, I didn't set StandardOutput and StandardError in service config. That explains it.
p2pool_stop.sh writes exit to the named pipe then waits for the process to terminate:
@twlee79 This shouldn't be necessary, p2pool handles SIGKILL, SIGINT, SIGTERM and SIGBREAK signals and exits gracefully, so you only need to set a timeout.
I don't like journal that is why i discard this option. I only enable this time for pure testing and worked.
Now use my previous config (not twlee79) and only enable StandardError=journal because i'm special now is working, not script and put directly p2pool commands in ExecStart that is. As explain SChernykh not need script for stop services p2pool do the job.
I'm not sure if correct way to assign StandardError for avoid infinite loop in the log but i least i'm fine with it, if you can find a fix for that would be nice though.
So you didn't add StandardOutput=journal
and it still worked, with only StandardError=journal
? With ListenFIFO
in config?
@twlee79 This shouldn't be necessary, p2pool handles SIGKILL, SIGINT, SIGTERM and SIGBREAK signals and exits gracefully, so you only need to set a timeout.
@SChernykh I assumed this was probably the case (that it would exit properly anyway) but I based the configuration on a standard template for controlling a console service by a named pipe, which exits the program via a console command.
@SnAFKe You don't have to use the journal, there are plenty of other systemd options you could use, but I would advise not using the same named pipe as StandardInput
for StandardOutput
or StandardError
(whether explicitly or implicitly by not specifying an option) because that to me is an obvious systemd configuration error that could easily break something in the future (such a systemd configuration is by itself creating a loop).
So you didn't add
StandardOutput=journal
and it still worked, with onlyStandardError=journal
? WithListenFIFO
in config?
Yes, i only need to add StandardError=journal
@SnAFKe You don't have to use the journal, there are plenty of other systemd options you could use, but I would advise not using the same named pipe as
StandardInput
forStandardOutput
orStandardError
(whether explicitly or implicitly by not specifying an option) because that to me is an obvious systemd configuration error that could easily break something in the future (such a systemd configuration is by itself creating a loop).
I'm not Systemd user so i don't have much knowledge, are you saying i only need to use one of them or what is the best config to use systemd service in p2pool without using journal?
@lexo-mfleuti @SnAFKe @twlee79 I've submitted https://github.com/SChernykh/p2pool/commit/44d2005ab1b1dd290d7d81d1bf7a8680ddf9a832 because the issue wasn't there. Latest code should still work with the proper service config.
@SChernykh Thank you very much! It works now with the latest commit. Also when I enable the FIFO socket there's no more millions of entries in the log if I redirect all output to Journal - which is not what I want though.
Despite the service starting up OK and seem to work normally with FIFO socket enabled, the command echo "status" > /tmp/p2pool.stdin
does not work. It just stalls and does nothing. I will disable that again but it would be nice if it worked. Executing the status command once in a while would give some valuable information.
My current configs:
[Unit]
Description=P2Pool Full Node
After=network.target p2pool.socket
Requires=monerod.service
BindsTo=p2pool.socket
[Service]
StandardInput=socket
Sockets=p2pool.socket
WorkingDirectory=/opt/p2pool/build/
Type=simple
Restart=always
ExecStartPre=/bin/bash -c '[[ -p /tmp/p2pool.stdin ]] && rm /tmp/p2pool.stdin; mkfifo /tmp/p2pool.stdin; exit 0' ### recreate the FIFO file on every start
ExecStartPre=sysctl vm.nr_hugepages=3072
ExecStart=/opt/p2pool/build/p2pool --loglevel 4 --host 127.0.0.1 --wallet ABC
TimeoutStopSec=60
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
[Unit]
Description=P2Pool Socket
[Socket]
ListenFIFO=/tmp/p2pool.stdin
NoDelay=true ### I also tried without this parameter, same issue
RemoveOnStop=true
[Install]
WantedBy=sockets.target
I'm not Systemd user so i don't have much knowledge, are you saying i only need to use one of them or what is the best config to use systemd service in p2pool without using journal?
Based on this systemd manual page, if you leave StandardOutput
as blank, it will default to inherit
which duplicates the file descriptor used for StandardInput
. When using ListenFIFO
this will loop anything written to StandardOutput
back to StandardInput
, which isn't desirable. There are other options including writing to a file, see the link provided.
If you leave StandardError
as blank, it generally defaults to inherit
which duplicates the file descriptor for StandardOutput
, potentially causing the same issues with looping back as noted above. (I presume this means that setting only StandardOutput
will work correctly, but I haven't tested this; I prefer the explicit configuration of StandardError
myself).
Presumably a configuration with only StandardError=journal
will work if the console messages causing the (worst of?) looping are being written to StandardError
and not StandardOutput
, but potentially issues could arise if anything written to StandardOutput
is looped back to StandardInput
.
@lexo-mfleuti If the FIFO socket is working correctly, you should be able to issue commands by echo
. You don't need to create the socket with mkfifo
, as the socket handles this itself. I would delete this line:
ExecStartPre=/bin/bash -c '[[ -p /tmp/p2pool.stdin ]] && rm /tmp/p2pool.stdin; mkfifo /tmp/p2pool.stdin; exit 0
This might be deleting your original named pipe created by p2pool.socket
and create a new FIFO, which presumably would invalidate the file descriptor provided to p2pool.service
by p2pool.socket
.
Otherwise, the obvious things to check for are:
1) Errors in your systemd journal for p2pool.socket
or p2pool.service
.
2) Is stdin detected as UV_NAMED_PIPE
? This is what my p2pool log shows when starting:
NOTICE 2023-04-20 04:13:12.3343 P2Pool v3.2 (built with GCC/11.2.1 on Mar 31 2023)
...
NOTICE 2023-04-20 04:13:12.6442 ConsoleCommands uv_guess_handle returned 7
NOTICE 2023-04-20 04:13:12.6443 ConsoleCommands processing stdin as UV_NAMED_PIPE
NOTICE 2023-04-20 04:13:12.6444 ConsoleCommands event loop started
...
the command echo "status" > /tmp/p2pool.stdin does not work
Try status
(without quotes).
Presumably a configuration with only
StandardError=journal
will work if the console messages causing the (worst of?) looping are being written toStandardError
and notStandardOutput
, but potentially issues could arise if anything written toStandardOutput
is looped back toStandardInput
.
In the end I think I'll leave it this way
StandardInput=socket
StandardOutput=null
Or maybe combination with File/append
@SChernykh @twlee79 Thanks a lot you guys. It's amazing, the moment you do it right, it works ;) With the latest build and the following config it all works fine now:
[Unit]
Description=P2Pool Full Node
After=network.target p2pool.socket
Requires=monerod.service
BindsTo=p2pool.socket
[Service]
StandardInput=socket
Sockets=p2pool.socket
WorkingDirectory=/opt/p2pool/build/
Type=simple
Restart=always
ExecStartPre=sysctl vm.nr_hugepages=3072
ExecStart=/opt/p2pool/build/p2pool --loglevel 4 --host 127.0.0.1 --wallet ABCD
TimeoutStopSec=60
StandardOutput=file:/opt/p2pool/build/stdout.log
StandardError=file:/opt/p2pool/build/error.log
[Install]
WantedBy=multi-user.target
[Unit]
Description=P2Pool Socket
[Socket]
ListenFIFO=/tmp/p2pool.stdin
#NoDelay=true
RemoveOnStop=true
[Install]
WantedBy=sockets.target
You were right @twlee79 , I did not need to create the FIFO file beforehand. It handles all by itself. By sending StandardOutput and StandardError to dedicated files and include those into the logrotate, for me, this is the perfect solution.
Happy mining people! ;)
I just built the p2pool binary from the latest sources and now when I start it through systemctl as a service it does not start anymore. Error:
I can start p2pool on the TTY console normally. I was trying to find a parameter to tell p2pool to not use the TTY and could not find any. Also I tried to configure the service to use a socket like this:
p2pool.service
[Install] WantedBy=multi-user.target
p2pool.socket