现象
在托盘处点击退出坚果云后, 坚果云自动重新启动, 在托盘处再次出现坚果云小图标
查看进程列表发现 “python3 /home/jianghuixin/.nutstore/dist/bin/nutstore-pydaemon.py” 命令一直都在, 没有结束
$ ps -ef | grep nutstore
猜测原因:
- 坚果云客户端在退出时, 会向 nutstore-pydaemon.py 进程发送 “exit” 的命令, 但这个过程失败了
- nutstore-pydaemon.py 进程的 watchDog 线程检测到客户端"意外"退出, 重新启动客户端
解决
坚果云的 GUI 客户端是由 java 封装编写的, 不方便修改, 可以修改 nutstore-pydaemon.py 文件中的代码, 在 JavaAppWatchDog.run
函数中禁止客户端重启(源代码文件的 381 行)
原有代码是 if restart_num > 10
, 现改为 if restart_num > 1
# Tell the java client how many times it has been restarted
restart_num = self.inc_and_get_restart_num()
if restart_num > 1:
logger.warning('We have restarted %d times, so abort it' % restart_num)
# avoid restarting the java client again and again. The threshold should be
# larger than the threshold of java client, which is 5 so that java client can detect the
# problem and notify the user. This should only be triggered when java client is
# crashed too early, e.g. the gnome/gtk environment is not ready and it can not
# be initialized
os._exit(-1)
首次启动 GUI 客户端时, restart_num 的值变为 1, 下一次试图启动客户端前 restart_num 的值变为 2, 由于大于 1, 进程结束