自动重启
可以设置 xSQL 在意外终止后自动重启。(请注意,目前此功能仅在 Linux 平台上实现。)
当 xSQL 以守护进程模式在服务器模式下运行(通过在命令行中指定 -daemon 选项)时,服务器进程会被分叉。然后父进程进入等待状态,等待子 xSQL 进程终止。如果 xSQL 子进程正常终止,父进程也会终止。如果子进程突然终止(通过任何类型的段错误),父进程会分叉出另一个子进程。如果数据库仅在内存中(仅包含临时类),则新子进程会打开一个空数据库。然而,如果数据库是基于磁盘的(仅包含持久类),新子进程会连接它。
自动重启通过配置文件中的 xlog_params 选项进行设置:
xlog_params : {
# Turn automatic restart on (true) or off (false) (default=true)
restart_server : true,
# Maximum number of restarts if the current server is terminated “too quickly“;
# i.e. the server is up for less than restart_quick_fail_time milliseconds.
# (default=3)
restart_n_quick_fail : 3,
# The time in milliseconds that is considered “too small”. Thus if the server is up
# for less than this number of milliseconds, it is restarted restart_n_quick_fail
# times before the parent process is terminated. (default=10*1000 i.e. 10 seconds)
restart_quick_fail_time : 10000,
}