swoole

启动脚本
cd /etc/init.d && vim swoole
#!/bin/sh
# chkconfig: 23456 90 10 
# description: start and reload swoole
php=/usr/local/bin/php
dir=/home/websocket.php
log=/home/log/swoole.json
case "$1" in   
        start)   
            nohup $php $dir >> $log 2>&1 &
            echo "start success"
            ;;
        status)
            ps -ef |grep swoole
            ;;
        restart)   
            echo "loading..."
            ps -eaf |grep "swoole" | grep -v "grep"| awk '{print $2}'|xargs kill -9
            sleep 2
            nohup $php $dir >> $log 2>&1 &
            echo "reload success"
            ;;
        stop)   
            echo "loading..."
            ps -eaf |grep "swoole" | grep -v "grep"| awk '{print $2}'|xargs kill -9
            echo "stop success"
            ;;
        *)   
            echo "Usage: /etc/init.d/swoole {start|status|restart|stop}" >&2  
            exit 1
esac


给权限

软连接 ln -s /etc/init.d/swoole  /usr/local/bin
chmod +x swoole

加入开机启动

chkconfig swoole on

header

originarray(20) {
  ["connection"]=>
  string(7) "Upgrade"
  ["x-forwarded-for"]=>
  string(14) "102.212.176.43"
  ["x-real-ip"]=>
  string(14) "102.212.176.43"
  ["host"]=>
  string(12) "0.0.0.0:9035"
  ["content-length"]=>
  string(2) "18"
  ["pragma"]=>
  string(8) "no-cache"
  ["cache-control"]=>
  string(8) "no-cache"
  ["sec-ch-ua"]=>
  string(66) ""Google Chrome";v="87", "\"Not;A\\Brand";v="99", "Chromium";v="87""
  ["accept"]=>
  string(3) "*/*"
  ["x-requested-with"]=>
  string(14) "XMLHttpRequest"
  ["sec-ch-ua-mobile"]=>
  string(2) "?1"
  ["user-agent"]=>
  string(135) "Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Mobile Safari/537.36"
  ["content-type"]=>
  string(33) "application/x-www-form-urlencoded"
  ["origin"]=>
  string(19) "https://www.jianshu.com"
  ["sec-fetch-site"]=>
  string(11) "same-origin"
  ["sec-fetch-mode"]=>
  string(4) "cors"
  ["sec-fetch-dest"]=>
  string(5) "empty"
  ["referer"]=>
  string(31) "https://www.baidu.com/test/4.html"
  ["accept-encoding"]=>
  string(17) "gzip, deflate, br"
  ["accept-language"]=>
  string(23) "zh-CN,zh;q=0.9,en;q=0.8"
}

server

array(11) {
  ["query_string"]=>
  string(7) "act=log"
  ["request_method"]=>
  string(4) "POST"
  ["request_uri"]=>
  string(10) "/wss/index"
  ["path_info"]=>
  string(10) "/wss/index"
  ["request_time"]=>
  int(1610016667)
  ["request_time_float"]=>
  float(1610016667.6672)
  ["server_protocol"]=>
  string(8) "HTTP/1.1"
  ["server_port"]=>
  int(9135)
  ["remote_port"]=>
  int(54242)
  ["remote_addr"]=>
  string(9) "127.0.0.1"
  ["master_time"]=>
  int(1610016667)
}

你可能感兴趣的:(swoole)