提示
以下内容的目的,只是为了学习合法的知识
shsupervisor:要安装的软件的名称。 supervisord:装好supervisor软件后,supervisord用于启动supervisor服务。 supervisorctl:用于管理supervisor配置文件中program。
使用yum命令安装 切换为root用户
shyum install epel-release # 如果已安装EPEL源,请跳过
yum install -y supervisor
systemctl enable supervisord # 开机自启动
systemctl start supervisord # 启动supervisord服务
systemctl status supervisord # 查看supervisord服务状态
ps -ef|grep supervisord # 查看是否存在supervisord进程
相关信息
TCP粘包和拆包理解
相关信息
给定一个二叉树, 找到该树中两个指定节点的最近公共祖先。
jspackage main
import (
"fmt"
)
// 给定一个二叉树, 找到该树中两个指定节点的最近公共祖先。
// 最近公共祖先的定义:“对于有根树 T 的两个结点 p、q,最近公共祖先表示为一个结点 x,
// 满足 x 是 p、q 的祖先且 x 的深度尽可能大(一个节点也可以是它自己的祖先)。”
// 例如,如下二叉树: Integer[] levelOrder = {3,5,1,6,2,0,8,null,null,7,4};
// 3
// 5 1
// 6 2 0 8
// 7 4
type TreeNode struct {
Val int
Left *TreeNode
Right *TreeNode
}
func main() {
// 构建二叉树
root := &TreeNode{Val: 3}
root.Left = &TreeNode{Val: 5}
root.Right = &TreeNode{Val: 1}
root.Left.Left = &TreeNode{Val: 6}
root.Left.Right = &TreeNode{Val: 2}
root.Right.Left = &TreeNode{Val: 0}
root.Right.Right = &TreeNode{Val: 8}
root.Left.Right.Left = &TreeNode{Val: 7}
root.Left.Right.Right = &TreeNode{Val: 4}
// 测试最近公共祖先
p := root.Left.Right.Left
q := root.Left.Right.Right
lca := lowestCommonAncestor(root, p, q)
fmt.Println("最近公共祖先:", lca.Val)
// fmt.Println("Hello world!")
}
func lowestCommonAncestor(root, p, q *TreeNode) *TreeNode {
if root == nil || root == p || root == q {
return root
}
left := lowestCommonAncestor(root.Left, p, q)
right := lowestCommonAncestor(root.Right, p, q)
if left != nil && right != nil {
return root
}
if left != nil {
return left
}
return right
}