我为bitcoind提供了一个upstart脚本,它基于本主题中的脚本:https://bitcointalk.org/index.php?topic=25518.0
我强烈需要重生未来的工作:如果发生了什么事,比特币应该自动重新启动。我试着模仿这种情况,但暴发户并没有重新启动这个过程。
问题:如果发生了一些不好的事情,我如何使新启动(或其他什么)观看和重新启动它?
实际脚本:
description "bitcoind"
start on filesystem
stop on runlevel [!2345]
oom never
expect daemon
respawn
respawn limit 10 60 # 10 times in 60 seconds
script
user=root
home=/root/.bitcoin/
cmd=/usr/bin/bitcoind
pidfile=$home/bitcoind.pid
# Don't change anything below here unless you know what you're doing
[[ -e $pidfile && ! -d "/proc/$(cat $pidfile)" ]] && rm $pidfile
[[ -e $pidfile && "$(cat /proc/$(cat $pidfile)/cmdline)" != $cmd* ]] && rm $pidfile
exec start-stop-daemon --start -c $user --chdir $home --pidfile $pidfile --startas $cmd -b -m
end script发布于 2014-06-12 23:35:58
oom never是你的第一个问题。你需要这个:
oom score never此外,除了关键系统服务之外,不要使用oom评分。试试-500或-700。与大多数进程相比,这应该是一个更高的优先级,但对于任何运行中的系统来说,这都是不可缺少的。所以你应该用:
oom score -500第二个问题是,您使用的是启动停止守护进程。你应该抛弃它,因为Upstart可以处理所有的事情。因此,生成的脚本如下所示:
description "bitcoind"
start on filesystem
stop on runlevel [!2345]
oom score -500
chdir /root/.bitcoin
respawn
respawn limit 10 60 # 10 times in 60 seconds
exec /usr/bin/bitcoind最后一个问题可能是您没有正确定义normal exit。您需要指定哪些返回代码和信号构成正常退出,以便Upstart知道如果信号和返回代码不匹配,就会重新出现。请参阅Upstart关于如何实现此操作的食谱:http://upstart.ubuntu.com/cookbook/#normal-exit。
发布于 2014-09-08 19:40:15
所以我终于在Ubuntu14.04服务器上完成了工作。下面是最后一个工作的/etc/init/bitcoind.conf是什么样子的:
description "bitcoind"
start on filesystem
stop on runlevel [!2345]
oom score -500
expect fork
respawn
respawn limit 10 60 # 10 times in 60 seconds
script
    user=bitcoind
    home=/home/$user
    cmd=$home/bin/bitcoind
    pidfile=$home/bitcoind.pid
    # Don't change anything below here unless you know what you're doing
    [[ -e $pidfile && ! -d "/proc/$(cat $pidfile)" ]] && rm $pidfile
    [[ -e $pidfile && "$(cat /proc/$(cat $pidfile)/cmdline)" != $cmd* ]] && rm $pidfile
    exec start-stop-daemon --start -c $user --chdir $home --pidfile $pidfile -m --startas $cmd
end script添加/更新/etc/init/bitcoin.conf文件后,请确保运行以下命令:
initctl reload-configuration基本上,这只是大量的猜测和检查,以使这最后的工作。以下是最重要的一点:
expect fork本质上,这是告诉新启动者在启动时目标进程将分叉多少次。如果你说错了,它就会在开始时挂起来。有关这方面的细节,请阅读这里。
另外,安装/运行bitcoind的用户是bitcoind,而不是root。
您应该能够作为服务手动启动bitcoind,如下所示:
service bitcoind start或者阻止它,像这样:
service bitcoind stop如果重新启动服务器,应自动启动bitcoind服务。而且,如果bitcoind进程被终止或崩溃,它将被自动恢复。您可以通过首先找到bitcoind进程的PID来在服务器上测试该部分:
ps cax | grep bitcoind然后,手动终止该过程:
kill -9 PID_OF_BITCOIND然后,再次尝试获取bitcoind进程的PID:
ps cax | grep bitcoind它应该仍然在运行,并有一个新的PID。
发布于 2014-11-12 13:51:20
现在有一个关于官方比特币项目的拉请求,其中包括建设得更好的新贵工作。
https://stackoverflow.com/questions/24163172
复制相似问题