Supervisor进程管理

Supervisor进程管理

概述:supervisor 是一个用 python 语言编写的进程管理工具,它可以很方便的监听、启动、停止、重启一个或多个进程。当一个进程意外被杀死,supervisor 监听到进程死后,可以很方便的让进程自动恢复,不再需要程序员或系统管理员自己编写代码来控制。

1.构成要素

  • Supervisord:

    • supervisor的服务端:运行supervisor时会启动一个进程supervisord;
    • 它负责启动所管理的进程,并将所管理的进程作为自己的子进程来启动;
    • 而且可以在所管理的进程出现崩溃时自动重启;
  • supervisorctl

    • supervisor 的客户端:supervisorctl 是命令行管理工具,可以用命令来进行子进程的管理

    • supervisorctl 常见命令

      命令含义
      supervisorctl status查看所有子进程的服务状态
      supervisorctl restart重启所有子进程服务
      supervisorctl restart name重启子进程名字为 name 的服务
      supervisorctl start name开启子进程为 name 的服务
      supervisorctl stop all关闭所有子进程服务
      supervisorctl stop name停止子进程为 name 的服务
      supervisorctl shutdown关闭所有的子进程服务,同时关闭supervisor工具本身
      supervisorctl reload重载配置文件,重启所有子进程服务
      supervisorctl update更新所有服务,一般用在添加新服务后
      supervisorctl update name更新子进程名字为 name 的服务
  • echo_supervisord_conf

    • echo_supervisord_conf是Supervisor的一个内置命令,用于生成Supervisor配置文件的模板。使用该命令可以快速生成一个示例的Supervisor配置文件,然后根据需要进行修改和扩展。

    • 要使用echo_supervisord_conf命令,您需要执行以下步骤:

      # 1. 打开终端或命令行窗口。
      # 2. 运行以下命令:
      echo_supervisord_conf > supervisord.conf
      

      这会将Supervisor的模板配置文件输出到名为 supervisord.conf 的文件中。

      1. 打开生成的 supervisord.conf 文件,您将看到一个模板配置文件的内容。

        该文件包含了一些示例的配置段,如[unix_http_server][supervisord][supervisorctl],以及一些默认设置的注释说明。

      2. 根据您的实际需求,在 supervisord.conf 文件中进行修改和扩展,添加您自己的进程配置。您可以指定进程的命令、日志文件路径、启动和停止脚本等。

      3. 保存修改后的 supervisord.conf 文件。

      现在,您可以使用生成的 supervisord.conf 文件作为Supervisor的配置文件,并通过 supervisord 命令启动Supervisor,以管理您的进程。请确保在启动 supervisord 前已经安装好了Supervisor,并将 supervisord 命令添加到系统的服务启动项或以守护进程的方式运行。

    • 产生的模板文件

      ; Sample supervisor config file.
      ;
      ; For more information on the config file, please see:
      ; http://supervisord.org/configuration.html
      ;
      ; Notes:
      ;  - Shell expansion ("~" or "$HOME") is not supported.  Environment
      ;    variables can be expanded using this syntax: "%(ENV_HOME)s".
      ;  - Quotes around values are not supported, except in the case of
      ;    the environment= options as shown below.
      ;  - Comments must have a leading space: "a=b ;comment" not "a=b;comment".
      ;  - Command will be truncated if it looks like a config file comment, e.g.
      ;    "command=bash -c 'foo ; bar'" will truncate to "command=bash -c 'foo ".
      ;
      ; Warning:
      ;  Paths throughout this example file use /tmp because it is available on most
      ;  systems.  You will likely need to change these to locations more appropriate
      ;  for your system.  Some systems periodically delete older files in /tmp.
      ;  Notably, if the socket file defined in the [unix_http_server] section below
      ;  is deleted, supervisorctl will be unable to connect to supervisord.[unix_http_server]
      file=/tmp/supervisor.sock   ; the path to the socket file
      ;chmod=0700                 ; socket file mode (default 0700)
      ;chown=nobody:nogroup       ; socket file uid:gid owner
      ;username=user              ; default is no username (open server)
      ;password=123               ; default is no password (open server); Security Warning:
      ;  The inet HTTP server is not enabled by default.  The inet HTTP server is
      ;  enabled by uncommenting the [inet_http_server] section below.  The inet
      ;  HTTP server is intended for use within a trusted environment only.  It
      ;  should only be bound to localhost or only accessible from within an
      ;  isolated, trusted network.  The inet HTTP server does not support any
      ;  form of encryption.  The inet HTTP server does not use authentication
      ;  by default (see the username= and password= options to add authentication).
      ;  Never expose the inet HTTP server to the public internet.;[inet_http_server]         ; inet (TCP) server disabled by default
      ;port=127.0.0.1:9001        ; ip_address:port specifier, *:port for all iface
      ;username=user              ; default is no username (open server)
      ;password=123               ; default is no password (open server)[supervisord]
      logfile=/tmp/supervisord.log ; main log file; default $CWD/supervisord.log
      logfile_maxbytes=50MB        ; max main logfile bytes b4 rotation; default 50MB
      logfile_backups=10           ; # of main logfile backups; 0 means none, default 10
      loglevel=info                ; log level; default info; others: debug,warn,trace
      pidfile=/tmp/supervisord.pid ; supervisord pidfile; default supervisord.pid
      nodaemon=false               ; start in foreground if true; default false
      minfds=1024                  ; min. avail startup file descriptors; default 1024
      minprocs=200                 ; min. avail process descriptors;default 200
      ;umask=022                   ; process file creation umask; default 022
      ;user=supervisord            ; setuid to this UNIX account at startup; recommended if root
      ;identifier=supervisor       ; supervisord identifier, default is 'supervisor'
      ;directory=/tmp              ; default is not to cd during start
      ;nocleanup=true              ; don't clean up tempfiles at start; default false
      ;childlogdir=/tmp            ; 'AUTO' child log dir, default $TEMP
      ;environment=KEY="value"     ; key value pairs to add to environment
      ;strip_ansi=false            ; strip ansi escape codes in logs; def. false; The rpcinterface:supervisor section must remain in the config file for
      ; RPC (supervisorctl/web interface) to work.  Additional interfaces may be
      ; added by defining them in separate [rpcinterface:x] sections.[rpcinterface:supervisor]
      supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface; The supervisorctl section configures how supervisorctl will connect to
      ; supervisord.  configure it match the settings in either the unix_http_server
      ; or inet_http_server section.[supervisorctl]
      serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL  for a unix socket
      ;serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
      ;username=chris              ; should be same as in [*_http_server] if set
      ;password=123                ; should be same as in [*_http_server] if set
      ;prompt=mysupervisor         ; cmd line prompt (default "supervisor")
      ;history_file=~/.sc_history  ; use readline history if available; The sample program section below shows all possible program subsection values.
      ; Create one or more 'real' program: sections to be able to control them under
      ; supervisor.;[program:theprogramname]
      ;command=/bin/cat              ; the program (relative uses PATH, can take args)
      ;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
      ;numprocs=1                    ; number of processes copies to start (def 1)
      ;directory=/tmp                ; directory to cwd to before exec (def no cwd)
      ;umask=022                     ; umask for process (default None)
      ;priority=999                  ; the relative start priority (default 999)
      ;autostart=true                ; start at supervisord start (default: true)
      ;startsecs=1                   ; # of secs prog must stay up to be running (def. 1)
      ;startretries=3                ; max # of serial start failures when starting (default 3)
      ;autorestart=unexpected        ; when to restart if exited after running (def: unexpected)
      ;exitcodes=0                   ; 'expected' exit codes used with autorestart (default 0)
      ;stopsignal=QUIT               ; signal used to kill process (default TERM)
      ;stopwaitsecs=10               ; max num secs to wait b4 SIGKILL (default 10)
      ;stopasgroup=false             ; send stop signal to the UNIX process group (default false)
      ;killasgroup=false             ; SIGKILL the UNIX process group (def false)
      ;user=chrism                   ; setuid to this UNIX account to run the program
      ;redirect_stderr=true          ; redirect proc stderr to stdout (default false)
      ;stdout_logfile=/a/path        ; stdout log path, NONE for none; default AUTO
      ;stdout_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
      ;stdout_logfile_backups=10     ; # of stdout logfile backups (0 means none, default 10)
      ;stdout_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)
      ;stdout_events_enabled=false   ; emit events on stdout writes (default false)
      ;stdout_syslog=false           ; send stdout to syslog with process name (default false)
      ;stderr_logfile=/a/path        ; stderr log path, NONE for none; default AUTO
      ;stderr_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
      ;stderr_logfile_backups=10     ; # of stderr logfile backups (0 means none, default 10)
      ;stderr_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)
      ;stderr_events_enabled=false   ; emit events on stderr writes (default false)
      ;stderr_syslog=false           ; send stderr to syslog with process name (default false)
      ;environment=A="1",B="2"       ; process environment additions (def no adds)
      ;serverurl=AUTO                ; override serverurl computation (childutils); The sample eventlistener section below shows all possible eventlistener
      ; subsection values.  Create one or more 'real' eventlistener: sections to be
      ; able to handle event notifications sent by supervisord.;[eventlistener:theeventlistenername]
      ;command=/bin/eventlistener    ; the program (relative uses PATH, can take args)
      ;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
      ;numprocs=1                    ; number of processes copies to start (def 1)
      ;events=EVENT                  ; event notif. types to subscribe to (req'd)
      ;buffer_size=10                ; event buffer queue size (default 10)
      ;directory=/tmp                ; directory to cwd to before exec (def no cwd)
      ;umask=022                     ; umask for process (default None)
      ;priority=-1                   ; the relative start priority (default -1)
      ;autostart=true                ; start at supervisord start (default: true)
      ;startsecs=1                   ; # of secs prog must stay up to be running (def. 1)
      ;startretries=3                ; max # of serial start failures when starting (default 3)
      ;autorestart=unexpected        ; autorestart if exited after running (def: unexpected)
      ;exitcodes=0                   ; 'expected' exit codes used with autorestart (default 0)
      ;stopsignal=QUIT               ; signal used to kill process (default TERM)
      ;stopwaitsecs=10               ; max num secs to wait b4 SIGKILL (default 10)
      ;stopasgroup=false             ; send stop signal to the UNIX process group (default false)
      ;killasgroup=false             ; SIGKILL the UNIX process group (def false)
      ;user=chrism                   ; setuid to this UNIX account to run the program
      ;redirect_stderr=false         ; redirect_stderr=true is not allowed for eventlisteners
      ;stdout_logfile=/a/path        ; stdout log path, NONE for none; default AUTO
      ;stdout_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
      ;stdout_logfile_backups=10     ; # of stdout logfile backups (0 means none, default 10)
      ;stdout_events_enabled=false   ; emit events on stdout writes (default false)
      ;stdout_syslog=false           ; send stdout to syslog with process name (default false)
      ;stderr_logfile=/a/path        ; stderr log path, NONE for none; default AUTO
      ;stderr_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
      ;stderr_logfile_backups=10     ; # of stderr logfile backups (0 means none, default 10)
      ;stderr_events_enabled=false   ; emit events on stderr writes (default false)
      ;stderr_syslog=false           ; send stderr to syslog with process name (default false)
      ;environment=A="1",B="2"       ; process environment additions
      ;serverurl=AUTO                ; override serverurl computation (childutils); The sample group section below shows all possible group values.  Create one
      ; or more 'real' group: sections to create "heterogeneous" process groups.;[group:thegroupname]
      ;programs=progname1,progname2  ; each refers to 'x' in [program:x] definitions
      ;priority=999                  ; the relative start priority (default 999); The [include] section can just contain the "files" setting.  This
      ; setting can list multiple files (separated by whitespace or
      ; newlines).  It can also contain wildcards.  The filenames are
      ; interpreted as relative to this file.  Included files *cannot*
      ; include files themselves.;[include]
      ;files = relative/directory/*.ini
      

2.安装

本部分主要介绍ubuntu系统中进行安装的方式,其他系统中百度亦可;

2.1 使用 apt 安装

  1. 更新软件包列表:

    sudo apt update
    
  2. 安装Supervisor:

    sudo apt install supervisor
    
  3. 启动Supervisor服务:

    sudo systemctl start supervisor
    
  4. 验证Supervisor是否已经启动:

    sudo systemctl status supervisor
    

2.2 使用pip安装

# supervisor是基于python写的,所以使用pip来安装即可。
pip install supervisor
或者
pip3 install supervisor # 默认生成文件的路径
# supervisord 路径
/usr/local/bin/supervisord
# supervisorctl 路径
/usr/local/bin/supervisorctl
# echo_supervisord_conf 路径
/usr/local/bin/echo_supervisord_conf

如上路径,我们也可以通过whereis supervisordwhereis supervisorctlwhereis echo_supervisord_conf得到

验证是否安装成功supervisorctl --help

3.配置详解

supervisor 进程管理服务程序安装完毕后,会在系统同中生成两个配置文件:

主进程配置文件:/etc/supervisor/supervisord.conf

子进程配置文件: /etc/supervisor/conf.d;子进程可能有多个配置文件;

3.1 默认主配置文件

supervisor 进程默认产生的配置文件如下所示;

image-20230916184052736

内容详解

; supervisor config file[unix_http_server]  ; 将unix_http_server 下的 file 路径改成如下内容
file=/var/run/supervisor.sock   ; (the path to the socket file)
chmod=0700                       ; sockef file mode (default 0700);unix_http_server 下的 file 路径改成如下内容
[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor            ; ('AUTO' child log dir, default $TEMP);以下部分必须保留在RPC的配置文件中
;(supervisorctl/web接口)要工作,可以使用其他接口
;通过在单独的rpcinterface:节中定义它们来添加
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface;supervisor 客户端
[supervisorctl]
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL  for a unix socket;[include]部分可以只包含“files”设置。这
;设置可以列出多个文件(用空格或
;换行符)。它还可以包含通配符。文件名为
;解释为相对于此文件。包含的文件*不能*
;包括文件本身。
[include]  ; 包括路径下的所有文件;
files = /etc/supervisor/conf.d/*.conf

上面的路径只是推荐路径,可以根据自己的想法指向不同的路径;

# 创建文件
#touch /var/run/supervisor.sock  # 依据配置文件自动创建mkdir /var/log/supervisor
touch /var/log/supervisor/supervisord.log#touch /var/run/supervisord.pid  # 依据配置文件自动创建
mkdir /etc/supervisor/conf.d
# 添加权限
#chmod 777 /var/run 
#chmod 777 /var/log

3.2 子进程服务常用的配置解析

**说明:**更详细的配置参考模板部分的信息,使用的时候通常将该文件放在conf.d目录下;

[program:your_program_name]
command=/path/to/your_executable --arg1=value1 --arg2=value2  ; 子进程的启动命令及参数
directory=/path/to/your_working_directory                  ; 子进程的工作目录
user=your_username                                        ; 子进程运行的用户
autostart=true                                            ; 设置为自动启动子进程
autorestart=true                                          ; 允许自动重启
startretries=3                                            ; 启动重试次数
redirect_stderr=true                                      ; 将标准错误输出重定向到Supervisor日志
stdout_logfile=/path/to/your_stdout_log_file               ; 子进程的标准输出日志路径

4. 配置案例

主要用来描述并编写常见的supervisor相关的系统,主要有djangoflaskpython 脚本nginxmysqldocker等常见进程工具的部署后的进程监控的配置;

4.1 django 程序监控的配置

[program:your_django_program]
command=/path/to/your_virtualenv/bin/gunicorn your_django_project.wsgi:application --bind 127.0.0.1:8000  ; Django程序的启动命令
directory=/path/to/your_django_project                  ; Django程序的根目录
user=your_username                                      ; Django程序运行的用户
autostart=true                                          ; 设置为自动启动
autorestart=true                                        ; 允许自动重启
startretries=3                                          ; 启动重试次数
redirect_stderr=true                                    ; 将标准错误输出重定向到Supervisor日志
stdout_logfile=/path/to/your_stdout_log_file             ; 标准输出日志路径
environment=PATH="/path/to/your_virtualenv/bin"          ; 设置虚拟环境的路径

执行如下命令;

# 复制文件到指定的目录
sudo ./my_app.conf /etc/supervisor/conf.d/

读取并更新配置文件

# 读取
sudo supervisorctl reread
# 更新配置文件
sudo supervisorctl update
# 启动
sudo supervisorctl start my_app

4.2 flask 配置

  • 创建一个新的Supervisor配置文件,例如 your_flask_program.conf

  • 在配置文件中添加以下配置:

    [program:your_flask_program]
    command=/path/to/your_virtualenv/bin/gunicorn your_flask_app:app --bind 127.0.0.1:8000  ; Flask程序的启动命令
    directory=/path/to/your_flask_app                  ; Flask程序的根目录
    user=your_username                                 ; Flask程序运行的用户
    autostart=true                                     ; 设置为自动启动
    autorestart=true                                   ; 允许自动重启
    startretries=3                                     ; 启动重试次数
    redirect_stderr=true                               ; 将标准错误输出重定向到Supervisor日志
    stdout_logfile=/path/to/your_stdout_log_file        ; 标准输出日志路径
    environment=PATH="/path/to/your_virtualenv/bin"     ; 设置虚拟环境的路径
    
    • 在上述配置中,将 /path/to/your_virtualenv 替换为您的虚拟环境的路径,将 your_flask_app 替换为您的Flask应用程序的目录名称,将 your_flask_app:app 替换为您的Flask应用程序的 app 对象所在的模块和变量名。

    • 根据实际需要修改 --bind 参数以指定Gunicorn绑定的地址和端口。

    • 使用 export 命令设置虚拟环境的路径。

    • 通过 supervisorctl 命令启动Supervisor,并指定刚刚创建的配置文件:

      supervisorctl -c /path/to/your_supervisor.conf
      这样,Supervisor将在指定的虚拟环境中启动并监控Flask应用程序。
      请确保在启动Supervisor之前,虚拟环境已安装好,并存储了Flask程序所需的依赖。
      在使用Supervisor监控Flask程序时,请确保在虚拟环境中正确安装了Gunicorn,并提供了有效的启动命令和相关配置。
      
  • 方式二

    [program:my_app]
    command=/home/whj/data/envs/learn_code/bin/gunicorn -b 0.0.0.0:9000 -w 3 app:app
    directory=/home/whj/data/code/learn_code/ubuntu_code/learn
    user=whj
    autostart=true
    autorestart=true
    redirect_stderr=true
    stdout_logfile=/home/whj/data/log/my_log.log
    

    执行如下命令;

    # 复制文件到指定的目录
    sudo ./my_app.conf /etc/supervisor/conf.d/
    

    读取并更新配置文件

    # 读取
    sudo supervisorctl reread
    # 更新配置文件
    sudo supervisorctl update
    # 启动
    sudo supervisorctl start my_app
    

4.3 python脚本的监控

假设服务名称为test。启动文件为py类文件entry.py

[program:my_my]  ;指定名称
command=/home/whj/data/envs/learn_code/bin/python print_sleep.py    ; 启动路径
directory=/home/whj/data/code/learn_code/ubuntu_code/learn			; 代码路径
user=whj
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/home/whj/data/log/my_py.log  ; 指定日志输出

supervisor 未启动的时候使用如下命令启动

# 读取配置文件
sudo suppervisorctl reread
# 更新配置文件
sudo suppervisorctl update
# 服务启动
sudo supervisorctl start my_my  # 指定启动的名称,通常执行完成 update 之后服务已经会启动了,本句命令也可以用作检验使用;

4.4 docker监控

Supervisor 可以监控和管理 Docker 容器的状态,通过使用 Supervisor 的program配置项,指定Docker命令启动和停止容器。

以下是监控Docker容器状态的一般步骤:

  1. 安装Supervisor:使用适合您的系统的方法安装Supervisor。
  2. 创建Supervisor配置文件:创建Supervisor的配置文件,例如docker.conf
[program:mydockercontainer]
command=docker run --name mycontainer myimage
autostart=true
autorestart=true

在上述配置中,mydockercontainer是容器的名称,command指定了启动容器的Docker命令。

可以根据实际需要,在command中添加其他选项,如端口映射、环境变量等。

  1. 更新Supervisor配置:运行以下命令更新Supervisor的配置。
$ supervisorctl reread
$ supervisorctl update
  1. 启动Docker容器:运行以下命令启动Docker容器。
$ supervisorctl start mydockercontainer

现在,Supervisor会监控Docker容器的状态,并在需要时自动重启容器。

如果需要停止或重启Docker容器,可以使用以下命令:

$ supervisorctl stop mydockercontainer
$ supervisorctl restart mydockercontainer

通过配置Supervisor来管理和监控Docker容器,可以确保容器的稳定运行,并在崩溃或停止时自动重启。此外,Supervisor还提供了其他功能,如日志管理和进程管控等,可以进一步提高对Docker容器的监控和管理能力。

5.supervisor 开机自动启动

一般使用supervisor开机自动启动服务,路径/usr/lib/systemd/system/supervisor.service

[Unit]
Description=Supervisor process control system for UNIX
Documentation=http://supervisord.org
After=network.target[Service]
ExecStart=/usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf
ExecStop=/usr/bin/supervisorctl $OPTIONS shutdown
ExecReload=/usr/bin/supervisorctl -c /etc/supervisor/supervisord.conf $OPTIONS reload
KillMode=process
Restart=on-failure
RestartSec=50s[Install]
WantedBy=multi-user.target

使用 apt 安装的时候默认存在该文件;

# 设置开机自动启动
systemctl enable supervisor
# 检查配置是否成功
systemctl is-enabled supervisor.service

image-20230916232649337

继续努力,终成大器!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.xdnf.cn/news/141800.html

如若内容造成侵权/违法违规/事实不符,请联系一条长河网进行投诉反馈,一经查实,立即删除!

相关文章

Linux查看哪些进程占用的系统 buffer/cache 较高 (hcache,lsof)命令

1、什么是buffer/cache ? buffer/cache 其实是作为服务器系统的文件数据缓存使用的,尤其是针对进程对文件存在 read/write 操作的时候,所以当你的服务进程在对文件进行读写的时候,Linux内核为了提高服务的读写速度,则将…

SpringBoot整合阿里云发送短信 (demo)

1. 登录阿里云 - 搜索【短信服务】- 套餐【立即购买】 2. 添加签名 国内消息 - 签名管理 - 添加签名 3. 添加模板 国内消息 - 模板管理 - 添加模板 模板详细 4. 依赖 <!--阿里云短信服务--> <dependency><groupId>com.aliyun</groupId><artifactI…

位移贴图的实现原理

在以前的文章中介绍过GLTF编辑器 &#xff0c; 编辑器可以对模型的各种材质纹理进行编辑修改&#xff0c;但是有一些新手用户可能对这些材质纹理不太了解&#xff0c;所以我收集了一些资料对这些材质纹理做一下详细的介绍&#xff0c;今天这篇文章主要是介绍位移贴图。 1、什么…

代码随想录算法训练营day6| 哈希表理论基础、242.有效的字母异位词、349. 两个数组的交集、202. 快乐数、1. 两数之和

目录 一、哈希表理论 hash function ​编辑hash collision 常见哈希结构 1&#xff09;set 2&#xff09;map 二、&#xff08;leetcode 242&#xff09;有效的字母异位词 三、&#xff08;leetcode 349&#xff09;两个数组的交集 四、&#xff08;leetcode 202&…

游戏录屏软件推荐,教你录制高清游戏视频

“有没有好用的游戏录屏软件推荐呀&#xff0c;最近当上了游戏主播&#xff0c;平台要求每天都要发一个游戏视频&#xff0c;可是我的游戏录屏软件太拉胯了&#xff0c;录制出来的视频非常糊&#xff0c;导致平台审核不通过&#xff0c;所以想问问大家有没有游戏录屏软件推荐一…

Pycharm2023版修改镜像源

步骤1 步骤2 国内常见镜像源 阿里云 http://mirrors.aliyun.com/pypi/simple/中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/豆瓣(douban) http://pypi.douban.com/simple/清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/中国科学技术大学 http://pypi.mirrors.…

创建Tensor

1、从numpy导入 注&#xff1a;从np导入的Float其实是DOUBLE类型 a np.array([2, 3.3]) torch.from_numpy(a)a np.ones([2,3]) torch.from_numpy(a)2、从list导入 torch.tensor([2., 3.2])torch.FloatTensor([2., 3.2]) #或者Tensor&#xff0c;可以接受shape&#xff0c;…

论文速览【序列模型 seq2seq】—— 【Ptr-Net】Pointer Networks

标题&#xff1a;Pointer Networks文章链接&#xff1a;Pointer Networks参考代码&#xff08;非官方&#xff09;&#xff1a;keon/pointer-networks发表&#xff1a;NIPS 2015领域&#xff1a;序列模型&#xff08;RNN seq2seq&#xff09;改进 / 深度学习解决组合优化问题【…

【基于MBD开发模式的matlab持续集成(一)】

基于MBD开发模式的matlab持续集成 引言 或许是感受到行业内卷的愈加激烈&#xff0c;在传统制造和高新技术相结合的新能源领域对软件工程开发的要求也愈加提高&#xff0c;尤其在互联网已经大行 其道的敏捷开发&#xff0c;便顺其自然的被新能源的老板们所看重。 概述 本文…

java面试题-设计模式基础

面试专题-设计模式 前言 在平时的开发中&#xff0c;涉及到设计模式的有两块内容&#xff0c;第一个是我们平时使用的框架&#xff08;比如spring、mybatis等&#xff09;&#xff0c;第二个是我们自己开发业务使用的设计模式。 面试官一般比较关心的是你在开发过程中&#…

Vue 学习笔记 错误ResizeObserver loop completed with undelivered notifications

环境Vue3 Ts 使用了el-table 后&#xff0c;容易出现如下错误 ERROR ResizeObserver loop completed with undelivered notifications. at handleError (webpack-internal:///./node_modules/webpack-dev-server/client/overlay.js:299:58) at eval (webpack-internal:///./nod…

基于FFmpeg+SDL的视频播放器的制作

基于FFmpegSDL的视频播放器的制作 基于FFmpegSDL的视频播放器的制作实验1实验2实验3实验4基本练习进阶练习 实验5 基于FFmpegSDL的视频播放器的制作 雷霄骅博士的课程。 课程链接&#xff1a;https://blog.csdn.net/leixiaohua1020/article/details/47068015 初学 FFmpeg&am…

PTE 口语练习准备(二)

目录 Day 1单词咬字专项 ChapterI 咬字练习之音书与辅音 Chapter 2咬字练习之“字典音 Chapter 3元“漏&#xff0c;加&#xff0c;换”语速练习 Day 1单词咬字专项 考量项目 单词 单词咬字也决定了句子呈现的位置 重音位置 电脑是有固有的模型的&#xff0c;给你的模型…

Python爬虫在Web应用自动化测试中的应用

在Web应用开发过程中&#xff0c;自动化测试是确保应用质量和稳定性的重要环节。本文将介绍如何使用Python爬虫与自动化测试技术相结合&#xff0c;实现对Web应用进行自动化测试的方法和步骤。通过这种结合&#xff0c;我们可以提高测试效率、减少人力成本&#xff0c;并确保应…

探索入行嵌入式应该要学会哪些知识?

入行嵌入式领域&#xff0c;需掌握嵌入式系统基础、C语言、C编程&#xff0c;了解微控制器、微处理器&#xff0c;学习电子电路基础&#xff0c;正好看我这一套保姆式嵌入式休息资料&#xff0c;里面包含了编程教学、数据处理、毕设800套和语言类教学&#xff0c;非常的全面、放…

自注意力机制

回顾以下注意力机制&#xff1a; 自注意力机制 Self-Attention的关键点 在于 K ≈ \approx ≈V ≈ \approx ≈Q 来源于同一个X&#xff0c;三者是同源的&#xff0c;通过 W Q W_Q WQ​, W K W_K WK​, W V W_V WV​做了一层线性变换。 接下来步骤和注意力机制一模一样。 …

开发者必备!如何将闲置iPad Pro打造为编程工具,使用VS Code编写代码

文章目录 前言1. 本地环境配置2. 内网穿透2.1 安装cpolar内网穿透(支持一键自动安装脚本)2.2 创建HTTP隧道 3. 测试远程访问4. 配置固定二级子域名4.1 保留二级子域名4.2 配置二级子域名 5. 测试使用固定二级子域名远程访问6. ipad pro通过软件远程vscode6.1 创建TCP隧道 7. ip…

Vue3最佳实践 第五章 Vue 组件应用 3( Slots )

5.4 Slots 我们已经了解到组件能够接收任意类型的 JavaScript 值作为 props&#xff0c;但组件要如何接收模板内容呢&#xff1f;在某些场景中&#xff0c;我们可能想要为子组件传递一些模板片段&#xff0c;让子组件在它们的组件中渲染这些片段。Slots 可用于将Html内容从父组…

一文了解什么SEO

搜索引擎优化 (SEO) 是一门让页面在 Google 等搜索引擎中排名更高的艺术和科学。 一、搜索引擎优化的好处 搜索引擎优化是在线营销的关键部分&#xff0c;因为搜索是用户浏览网络的主要方式之一。 搜索结果以有序列表的形式呈现&#xff0c;网站在该列表中的排名越高&#x…

指针笔试题讲解(让指针变得简单易懂)

数组名的理解 : 数组名就是首元素地址 但是有两个例外&#xff1a; 1. sizeof&#xff08;数组名&#xff09;这里的数组名表示整个数组的大小&#xff0c;sizeof&#xff08;数组名&#xff09;计算的是整个数组的大小&#xff0c;单位是字节 2. &数组名 这里的数组…