moneroexamples / onion-monero-blockchain-explorer

Onion Monero Blockchain Explorer
https://xmrchain.net
BSD 3-Clause "New" or "Revised" License
370 stars 269 forks source link

Run xmrblocks with exec #148

Closed normoes closed 4 years ago

normoes commented 6 years ago

TL;DR: The following error is thrown when doing:

exec xmrblocks -b /monero
2018-10-12 04:36:04,010 INFO  [default] Page size: 4096
"/monero"
2018-10-12 04:36:05.016     7f79ba675780    WARN    blockchain.db.lmdb  src/blockchain_db/lmdb/db_lmdb.cpp:75   Failed to create a read transaction for the db: Resource temporarily unavailable
terminate called after throwing an instance of 'cryptonote::DB_ERROR_TXN_START'
  what():  Failed to create a read transaction for the db: Resource temporarily unavailable

I can run xmrblocks, it's working fine.

xmrblocks -b /monero

I would like to run it within a docker container. However, for this purpose I use an entrypoint script like this:

#!/bin/bash

# used for xmrblocks
OPTIONS="-b $LMDB_PATH"  #  --port $PORT  --enable-autorefresh-option=$ENABLE_AUTOREFRESH"

if [[ "${1:0:1}" = '-' ]]  || [[ -z "$@" ]]; then
  set -- "xmrblocks $@ $OPTIONS"
fi

# allow the container to be started with `--user
if [ "$(id -u)" = 0 ]; then
  adduser --system --group --uid "$USER_ID" --shell /bin/false xmrblocks &> /dev/null
  exec su-exec xmrblocks xmrblocks $@
fi

exec $@

These are the lines that cause trouble:

  exec su-exec xmrblocks xmrblocks $@
  exec $@

If I leave the exec, everything will work just fine.

With the exec, the following error appears and xmrblocks just stops.

2018-10-12 04:36:04,010 INFO  [default] Page size: 4096
"/monero"
2018-10-12 04:36:05.016     7f79ba675780    WARN    blockchain.db.lmdb  src/blockchain_db/lmdb/db_lmdb.cpp:75   Failed to create a read transaction for the db: Resource temporarily unavailable
terminate called after throwing an instance of 'cryptonote::DB_ERROR_TXN_START'
  what():  Failed to create a read transaction for the db: Resource temporarily unavailable

Is there something I am missing?

moneroexamples commented 6 years ago

when you specify -b option you need to specify it to where lmdb folder of the monero blockchain is located.

normoes commented 6 years ago

Yes, I do that.

The command that is executed is xmrblocks -b /monero.

/monero contains data.mdb lock.mdb.

$LMDB_PATH contains the value /monero.

But the exact same command prefixed with exec is not working: exec xmrblocks -b /monero

normoes commented 6 years ago

I add the actual outputs here.

xmrblocks -b /monero

2018-10-12 06:36:44,105 INFO  [default] Page size: 4096
"/monero"
get_network_info: not connected to deamon
 Cant read network info 
get_mempool: not connected to deamon
Getting mempool failed 
Staring in non-ssl mode
(2018-10-12 06:36:45) [INFO    ] Crow/0.1 server is running at 0.0.0.0:8081 using 8 threads
(2018-10-12 06:36:45) [INFO    ] Call `app.loglevel(crow::LogLevel::Warning)` to hide Info level logs.
get_mempool: not connected to deamon
Getting mempool failed 

and

exec xmrblocks -b /monero

2018-10-12 06:36:56,733 INFO  [default] Page size: 4096
"/monero"
2018-10-12 06:36:57.748     7f2a36ae9780    WARN    blockchain.db.lmdb  src/blockchain_db/lmdb/db_lmdb.cpp:75   Failed to create a read transaction for the db: Resource temporarily unavailable
terminate called after throwing an instance of 'cryptonote::DB_ERROR_TXN_START'
  what():  Failed to create a read transaction for the db: Resource temporarily unavailable
moneroexamples commented 6 years ago

Sorry don't know what can be causing it. Using container to run it seems as a good idea, but I haven't attempted it, so don't know at present how could the issue be solved.

normoes commented 6 years ago

Basically it is working, though having it executed using exec is some kind of best practice to let it run as process 1. process 1 is managed by docker itself.

It would be nice if you could check on it some other time.

Thanks for the help.

moneroexamples commented 6 years ago

No problem. If you figure it out, please let me know.

normoes commented 6 years ago

Ok.

normoes commented 6 years ago

@moneroexamples

Whatever caused that, it is gone now - I cloned the current master branch and just tried it again.

I think, the issue can be closed.

normoes commented 5 years ago

Hey @moneroexamples

I need to reopen this issue. The error is back...

As far as I remember, it worked with this version: explorer version (api): master-2018-10-23-a46b1e7 (1.1) | monero version: 0.13.0.0-master-1e74586

Now, with the current master branch it does not work anymore: explorer version (api): master-2018-11-07-db8b46e (1.1) | monero version: 0.13.0.0-master-84dd674

moneroexamples commented 5 years ago

Maybe HIDAPI is causing it? The only major changes after 23 October were to replace PCSC dependency with HIDAPI (just like in monero).

https://github.com/moneroexamples/onion-monero-blockchain-explorer/commit/f168b4e83a7cc0e6469d3e77b24a1a3580ee01a1

Everything else is rather cosmetic.

normoes commented 5 years ago

Good point, I'll look into this.

nurviro commented 2 years ago

@normoes did you ever determine the root cause of this? I am running into the same symptom, although via a different method. I'm compiling monerod & xmrblocks successfully with musl on alpine, but getting the same exact error when I try to run.

Either I get the error in monerod or in xmrblocks - it depends which process I start first. The 2nd process to start throws the error.