TINYPROXY——PID文件读取错误

Posted rosebud7

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TINYPROXY——PID文件读取错误相关的知识,希望对你有一定的参考价值。

tinyproxy——A light-weight HTTP proxy daemon


 

描述:tinyproxy服务重启时报告PID文件无法打开错误,但服务启动成功。

    错误描述:tinyproxy.service: Can‘t open PID file /run/tinyproxy/tinyproxy.pid (yet?) after start: No such file or directory

    注:本人测试重启服务器后查看tinyproxy服务状态时并不会报告此错误,仅在重启tinyproxy服务时才会报错。

分析:PIDFile=指定了一个用于存储服务的PID的文件路径,对于Type=设置为forking的服务,建议使用此选项。

    系统管理器在服务启动后会从这个文件中读取服务主进程的PID,但是如果服务启动后该文件还没有写完,则会报告错误该文件不可读。

    为了使系统管理器读取时该文件已写完,需在服务启动后加入一段延时,这时需要用到ExecStartPost=命令来调用/bin/slep,参数为0.1。ExecStartPost=指令只会在ExecStart=调用成功后运行。

    命令调用顺序为:调用ExecStart=命令->调用ExecStartPost=命令->调用PIDFile=命令。

方案:    

1.打开文件/lib/systemd/system/tinyproxy.service并在[Service]选项下添加以下内容:

  ExecStartPost=/bin/sleep 0.1

2.重新加载systemd程序的配置文件

  systemctl daemon-reload

3.重启tinyproxy服务

  service tinyproxy restart

4.查看tinyproxy服务状态

  service tinyproxy status

 

注:系统服务命令的详细解释可参考文件systemd.service — Service unit configuration。

  网址:https://www.freedesktop.org/software/systemd/man/systemd.service.html

 


2020-05-13 16:16:56

 

以上是关于TINYPROXY——PID文件读取错误的主要内容,如果未能解决你的问题,请参考以下文章

centos 7:nginx 无法从文件 /run/nginx.pid 读取 PID:无效参数

c_cpp C读取pid文件

访问 `proc` 文件系统以从系统应用程序中读取 `/proc/[pid]/some-file`

解决nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed错误

解决nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed错误

autoit 读取没有id的网页