nginx,lua,shell执行服务器脚本问题connect to unix:/tmp/shell.sock failed 2: No such file or directory
参考文档:
https://www.code404.icu/830.html
shell.sock找不到的解决办法
connect() to unix:/tmp/shell.sock failed (2: No such file or directory)
按照参考文档中的来做的话,shell.sock被放到了/tmp目录下,但是使用过程中,一直报文件找不到。
解决办法是将shell.sock放到其他目录。
connect() to unix:/tmp/shell.sock failed (2: No such file or directory)
例如:
./sockproc /data/shell.sock
chmod 0666 /data/shell.sock
在lua中使用的时候更换下地址即可。
2021/06/23 17:24:20 [crit] 32063#0: *3941462 connect() to unix:/tmp/shell.sock failed (2: No such file or directory), client: 172.25.42.35, server: , request: "GET /test/ HTTP/1.1", host: "192.168.65.94:19999"
2021/06/23 17:24:30 [crit] 32155#0: *3941508 connect() to unix:/tmp/shell.sock failed (2: No such file or directory), client: 172.25.42.35, server: , request: "GET /test/ HTTP/1.1", host: "192.168.65.94:19999"
2021/06/23 17:24:45 [crit] 32568#0: *3941567 connect() to unix:/tmp/shell.sock failed (2: No such file or directory), client: 172.25.42.35, server: , request: "GET /test/ HTTP/1.1", host: "192.168.65.94:19999"
2021/06/23 17:25:06 [crit] 32568#0: *3941567 connect() to unix:/tmp/shell.sock failed (2: No such file or directory), client: 172.25.42.35, server: , request: "GET /test/ HTTP/1.1", host: "192.168.65.94:19999"
2021/06/24 08:08:57 [crit] 32568#0: *4105349 connect() to unix:/tmp/shell.sock failed (2: No such file or directory), client: 127.0.0.1, server: , request: "HEAD /test/ HTTP/1.1", host: "localhost:19999"
2021/06/24 08:08:59 [crit] 32568#0: *4105353 connect() to unix:/tmp/shell.sock failed (2: No such file or directory), client: 127.0.0.1, server: , request: "GET /test/ HTTP/1.1", host: "localhost:19999"
2021/06/24 08:10:30 [crit] 32569#0: *4105722 connect() to unix:/tmp/shell.sock failed (2: No such file or directory), client: 127.0.0.1, server: , request: "GET /test/ HTTP/1.1", host: "localhost:19999"
服务器重启后shell.sock无法连接
connect() to unix:/data/shell/shell.sock failed (111: Connection refused)
2021/06/24 08:08:57 [crit] 32568#0: *4105349 connect() to unix:/data/shell/shell.sock failed (111: Connection refused), client: 127.0.0.1, server: , request: "HEAD /test/ HTTP/1.1", host: "localhost:19999"
2021/06/24 08:08:59 [crit] 32568#0: *4105353 connect() to unix:/data/shell/shell.sock failed (111: Connection refused), client: 127.0.0.1, server: , request: "GET /test/ HTTP/1.1", host: "localhost:19999"
2021/06/24 08:10:30 [crit] 32569#0: *4105722 connect() to unix:/data/shell/shell.sock failed (111: Connection refused), client: 127.0.0.1, server: , request: "GET /test/ HTTP/1.1", host: "localhost:19999"
服务器重启后,就会报错
connect() to unix:/data/shell/shell.sock failed (111: Connection refused)
所以需要重新执行命令,给 /data/shell.sock 权限
./sockproc /data/shell.sock
chmod 0666 /data/shell.sock
我们可以把这两个命令放到开机启动时自动执行的脚本中。
vim /etc/rc.d/rc.local 内容如下:
touch /var/lock/subsys/local
sudo /usr/local/k8s/lua/sockproc/sockproc /data/shell/shell.sock
sudo chmod 0666 /data/shell/shell.sock