Bug 251269 - [PATCH] for and net-p2p/bitcoin-daemon to fix startup if datadir is customized
Summary: [PATCH] for and net-p2p/bitcoin-daemon to fix startup if datadir is customized
Status: Closed Not A Bug
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Kevin Bowling
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-11-20 13:15 UTC by Oleg (metacreo)
Modified: 2020-11-25 08:17 UTC (History)
1 user (show)

See Also:
kbowling: maintainer-feedback-


Attachments
patch (900 bytes, patch)
2020-11-20 13:15 UTC, Oleg (metacreo)
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Oleg (metacreo) 2020-11-20 13:15:21 UTC
Created attachment 219828 [details]
patch

Failed to start, auto-start if you specify custom datadir ir rc.conf
My 12.2-RELEASE on ZFS (SSD), bitcoind_data_dir mounted on /opt (HDD)
Normal run only with
pidfile="${bitcoind_data_dir}/${name}.pid"
and if removed -p ( ${daemon_command} -u "${bitcoind_user}" -f )

{
  echo "Starting bitcoind..."
  cd "${bitcoind_data_dir}" || return 1
  ${daemon_command} -u "${bitcoind_user}" -f \
    ${command} \
    -conf="${bitcoind_config_file}" \
    -datadir="${bitcoind_data_dir}"
}
Comment 1 Kevin Bowling freebsd_committer 2020-11-21 13:32:19 UTC
This patch does not make sense to me as is, the PID file was moved to deconflict the GUI client versus the daemon in PR #246792

Why are you moving the pidfile back to the data dir?  Does it work with a custom data dir but the new pid location?
Comment 2 Oleg (metacreo) 2020-11-21 15:46:30 UTC
Because if specified bitcoind_data_dir in rc.conf daemon not starting
but if pid file in bitcoind_data_dir and not declared in command 
${daemon_command} -u "${bitcoind_user}" -p "${pidfile}" -f \
bitcoind starting normaly.
Comment 3 Oleg (metacreo) 2020-11-21 15:50:17 UTC
I not have any GUI...
Not have X...
Machine running only as "web-server" with bitcoin-daemon
Comment 4 William MacKay 2020-11-24 20:02:00 UTC
I can't reproduce Oleg's issue on my own bitcoin-daemon installation. I specified bitcoind_data_dir in /etc/rc.conf and restarted the bitcoind service.  It happily started up in the new location.

I am using SVN revision 555537 "Move PID to /var/run" and I have not applied Oleg's patch. Oleg, could you please check your debug.log and see what error is reported?  I think we need more information than "failed to start".
Comment 5 Oleg (metacreo) 2020-11-24 22:26:49 UTC
Sorry 
I reinstalled bitcoin-daemon and now it start.
But I cannot stop it  

root@hostmy:~ # ps aux | grep bitc
root     16492   0.0  0.0    11540    2792  0  S+   00:12    0:00.00 grep bitc
root@hostmy:~ # service bitcoind status
Bitcoind is not running
root@hostmy:~ # service bitcoind start
Performing sanity check on bitcoind configuration:
Bitcoind is not running
Starting bitcoind:
root@hostmy:~ # service bitcoind status
Bitcoind is not running
root@hostmy:~ # ps aux | grep bitc
bitcoin  16510  11.1  0.6  2142272  434472  -  Ds   00:13    0:03.03 /usr/local/bin/bitcoind -conf=/usr/local/etc/bitcoin.conf -datadir=/opt/bitcoin/bitcoind
root     16524   0.0  0.0    11540    2792  0  S+   00:13    0:00.00 grep bitc
root@hostmy:~ # service bitcoind stop
Stopping bitcoind:
Bitcoind is not running
root@hostmy:~ # ps aux | grep bitc
bitcoin  16510   8.4  0.9  2269480  627484  -  Ss   00:13    0:24.02 /usr/local/bin/bitcoind -conf=/usr/local/etc/bitcoin.conf -datadir=/opt/bitcoin/bitcoind
root     16550   0.0  0.0    11540    2792  0  S+   00:17    0:00.00 grep bitc

bitcoind_enable="YES"
bitcoind_data_dir="/opt/bitcoin/bitcoind"

Original rc.d script
no pid in /var/run
pid in /opt/bitcoin/bitcoind
Comment 6 William MacKay 2020-11-24 23:12:38 UTC
"no pid in /var/run" is the cause of your problem. The pidfile is supposed to be at /var/run/bitcoind.pid . That file gets created for me.

Is it possible you have local changes to your /usr/local/etc/rc.d/bitcoind script?  Please compare against the one in Subversion:
https://svnweb.freebsd.org/ports/head/net-p2p/bitcoin/files/bitcoind.in?revision=555537&view=markup&pathrev=555537

The path to the pidfile is specified on line 36 and it is created on line 120. Do those match in your rc script? What happens if you run line 120 manually in a shell, do you see any error output?
Comment 7 Oleg (metacreo) 2020-11-25 08:17:32 UTC
I found the problem.
To reproduce just put "daemon=1" in /usr/local/etc/bitcoin.conf

I removed this line and all works fine. No bitcoin files in /var/db.
Now pid exist in 2 places in /var/run and specified data directory.

start/stop/restart all works
thank you