hhxsv5 / laravel-s

LaravelS is an out-of-the-box adapter between Laravel/Lumen and Swoole.
MIT License
3.83k stars 472 forks source link

Sdebug not working properly, maybe it is related to how laravel-s is coded specifically? #289

Open juslintek opened 4 years ago

juslintek commented 4 years ago
  1. Your software version (Screenshot of your startup)

    Software Version
    PHP 7.4.3
    Swoole 4.5.2
    Laravel 6.18.20
    Ubuntu 18.04
    Supervisord 3.3.1
    Laravel-s 3.7.3
  2. Detail description about this issue(error/log)

https://github.com/swoole/swoole-src/issues/1681

  1. Some reproducible code blocks and steps

Just create a project inside a docker image and try using xdebug to walk around the app. Break at multiple places, break before the start of the app, and after the start of the app.

laravel-s config

{
    "server": {
        "listen_ip": "0.0.0.0",
        "listen_port": 5200,
        "socket_type": 1,
        "enable_coroutine_runtime": false,
        "server": "LaravelS",
        "handle_static": false,
        "laravel_base_path": "/var/www/html",
        "inotify_reload": {
            "enable": true,
            "watch_path": "/var/www/html",
            "file_types": [
                ".php"
            ],
            "excluded_dirs": [],
            "log": true
        },
        "event_handlers": [],
        "websocket": {
            "enable": false
        },
        "sockets": [],
        "processes": {
            "COAWebSocketProcess": {
                "class": "App\\Processes\\COAWebSocketClientProcess",
                "redirect": false,
                "pipe": "0",
                "enable": true,
                "queue": {
                    "msg_key": 827637469,
                    "mode": 2,
                    "capacity": 8192
                },
                "restart_interval": 5
            },
            "CODWebSocketProcess": {
                "class": "App\\Processes\\CODWebSocketClientProcess",
                "redirect": false,
                "pipe": "0",
                "enable": true,
                "queue": {
                    "msg_key": 827637469,
                    "mode": 2,
                    "capacity": 8192
                },
                "restart_interval": 5
            }
        },
        "timer": {
            "enable": true,
            "jobs": [
                "Hhxsv5\\LaravelS\\Illuminate\\LaravelScheduleJob"
            ],
            "max_wait_time": 5
        },
        "swoole_tables": [],
        "register_providers": [
            "Laravel\\Horizon\\HorizonServiceProvider",
            "App\\Providers\\AzureLogicAppsProvider",
            "App\\Providers\\BroadcastServiceProvider",
            "App\\Providers\\EventServiceProvider",
            "App\\Providers\\RouteServiceProvider",
            "App\\Providers\\AuthServiceProvider"
        ],
        "cleaners": [
            "Hhxsv5\\LaravelS\\Illuminate\\Cleaners\\AuthCleaner",
            "Hhxsv5\\LaravelS\\Illuminate\\Cleaners\\SessionCleaner",
            "Hhxsv5\\LaravelS\\Illuminate\\Cleaners\\ConfigCleaner"
        ],
        "destroy_controllers": {
            "enable": false,
            "excluded_list": []
        },
        "swoole": {
            "daemonize": false,
            "dispatch_mode": 2,
            "reactor_num": 8,
            "worker_num": 8,
            "task_worker_num": 8,
            "task_ipc_mode": 1,
            "task_max_request": 8000,
            "task_tmpdir": "/dev/shm",
            "max_request": 8000,
            "open_tcp_nodelay": true,
            "pid_file": "/var/www/html/storage/laravels.pid",
            "log_file": "/var/www/html/storage/logs/laravels.log",
            "log_level": 1,
            "document_root": "/var/www/html/public",
            "buffer_output_size": 2097152,
            "socket_buffer_size": 134217728,
            "package_max_length": 4194304,
            "reload_async": true,
            "max_wait_time": 60,
            "enable_reuse_port": true,
            "enable_coroutine": true,
            "http_compression": true,
            "heartbeat_idle_time": 30,
            "heartbeat_check_interval": 10,
            "log_rotation": 0,
            "discard_timeout_request": false
        },
        "enable_gzip": false,
        "process_prefix": "/var/www/html",
        "ignore_check_pid": true
    },
    "laravel": {
        "root_path": "/var/www/html",
        "static_path": "/var/www/html/public",
        "cleaners": [
            "Hhxsv5\\LaravelS\\Illuminate\\Cleaners\\AuthCleaner",
            "Hhxsv5\\LaravelS\\Illuminate\\Cleaners\\SessionCleaner",
            "Hhxsv5\\LaravelS\\Illuminate\\Cleaners\\ConfigCleaner"
        ],
        "register_providers": [
            "Laravel\\Horizon\\HorizonServiceProvider",
            "App\\Providers\\AzureLogicAppsProvider",
            "App\\Providers\\BroadcastServiceProvider",
            "App\\Providers\\EventServiceProvider",
            "App\\Providers\\RouteServiceProvider",
            "App\\Providers\\AuthServiceProvider"
        ],
        "destroy_controllers": {
            "enable": false,
            "excluded_list": []
        },
        "is_lumen": false,
        ...
}

Nginx config:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
# configuration file /etc/nginx/nginx.conf:
user user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # SSL Settings
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

# configuration file /etc/nginx/modules-enabled/50-mod-http-auth-pam.conf:
load_module modules/ngx_http_auth_pam_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-http-dav-ext.conf:
load_module modules/ngx_http_dav_ext_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-http-echo.conf:
load_module modules/ngx_http_echo_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-http-geoip.conf:
load_module modules/ngx_http_geoip_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-http-geoip2.conf:
load_module modules/ngx_http_geoip2_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-http-image-filter.conf:
load_module modules/ngx_http_image_filter_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-http-subs-filter.conf:
load_module modules/ngx_http_subs_filter_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-http-upstream-fair.conf:
load_module modules/ngx_http_upstream_fair_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-http-xslt-filter.conf:
load_module modules/ngx_http_xslt_filter_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-mail.conf:
load_module modules/ngx_mail_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-ssl-ct.conf:
load_module modules/ngx_ssl_ct_module.so;
load_module modules/ngx_http_ssl_ct_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-stream.conf:
load_module modules/ngx_stream_module.so;

# configuration file /etc/nginx/mime.types:

types {
    text/html                             html htm shtml;
    text/css                              css;
    text/xml                              xml;
    image/gif                             gif;
    image/jpeg                            jpeg jpg;
    application/javascript                js;
    application/atom+xml                  atom;
    application/rss+xml                   rss;

    text/mathml                           mml;
    text/plain                            txt;
    text/vnd.sun.j2me.app-descriptor      jad;
    text/vnd.wap.wml                      wml;
    text/x-component                      htc;

    image/png                             png;
    image/tiff                            tif tiff;
    image/vnd.wap.wbmp                    wbmp;
    image/x-icon                          ico;
    image/x-jng                           jng;
    image/x-ms-bmp                        bmp;
    image/svg+xml                         svg svgz;
    image/webp                            webp;

    application/font-woff                 woff;
    application/java-archive              jar war ear;
    application/json                      json;
    application/mac-binhex40              hqx;
    application/msword                    doc;
    application/pdf                       pdf;
    application/postscript                ps eps ai;
    application/rtf                       rtf;
    application/vnd.apple.mpegurl         m3u8;
    application/vnd.ms-excel              xls;
    application/vnd.ms-fontobject         eot;
    application/vnd.ms-powerpoint         ppt;
    application/vnd.wap.wmlc              wmlc;
    application/vnd.google-earth.kml+xml  kml;
    application/vnd.google-earth.kmz      kmz;
    application/x-7z-compressed           7z;
    application/x-cocoa                   cco;
    application/x-java-archive-diff       jardiff;
    application/x-java-jnlp-file          jnlp;
    application/x-makeself                run;
    application/x-perl                    pl pm;
    application/x-pilot                   prc pdb;
    application/x-rar-compressed          rar;
    application/x-redhat-package-manager  rpm;
    application/x-sea                     sea;
    application/x-shockwave-flash         swf;
    application/x-stuffit                 sit;
    application/x-tcl                     tcl tk;
    application/x-x509-ca-cert            der pem crt;
    application/x-xpinstall               xpi;
    application/xhtml+xml                 xhtml;
    application/xspf+xml                  xspf;
    application/zip                       zip;

    application/octet-stream              bin exe dll;
    application/octet-stream              deb;
    application/octet-stream              dmg;
    application/octet-stream              iso img;
    application/octet-stream              msi msp msm;

    application/vnd.openxmlformats-officedocument.wordprocessingml.document    docx;
    application/vnd.openxmlformats-officedocument.spreadsheetml.sheet          xlsx;
    application/vnd.openxmlformats-officedocument.presentationml.presentation  pptx;

    audio/midi                            mid midi kar;
    audio/mpeg                            mp3;
    audio/ogg                             ogg;
    audio/x-m4a                           m4a;
    audio/x-realaudio                     ra;

    video/3gpp                            3gpp 3gp;
    video/mp2t                            ts;
    video/mp4                             mp4;
    video/mpeg                            mpeg mpg;
    video/quicktime                       mov;
    video/webm                            webm;
    video/x-flv                           flv;
    video/x-m4v                           m4v;
    video/x-mng                           mng;
    video/x-ms-asf                        asx asf;
    video/x-ms-wmv                        wmv;
    video/x-msvideo                       avi;
}

# Default server configuration
#
server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;

    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html;

    server_name _;

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;
    }
}

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

upstream swoole {
    server 127.0.0.1:5200 weight=5 max_fails=3 fail_timeout=30s;
    keepalive 16;
}

server {
    listen 80;
        listen 443 http2 ssl;
        #listen 80;

        server_name test.test;

        ssl_certificate      /etc/letsencrypt/live/test.test/fullchain.pem;
        ssl_certificate_key  /etc/letsencrypt/live/test.test/privkey.pem;

        root /home/user/project/public;
        index index.php;

    location /socket.io {
        proxy_pass http://localhost:6001; #could be localhost if Echo and NginX are on the same box
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "Upgrade";
    }

    location / {
                try_files $uri @laravels;
    }

    location ~* \.php$ {
                return 404;
        }

        location @laravels {
               proxy_http_version 1.1;
               proxy_connect_timeout 60s;
               proxy_send_timeout 60s;
               proxy_read_timeout 60s;
               proxy_set_header Connection "";
               proxy_set_header X-Real-IP $remote_addr;
               proxy_set_header X-Real-PORT $remote_port;
               proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
               proxy_set_header Host $http_host;
               proxy_set_header Scheme $scheme;
               proxy_set_header Server-Protocol $server_protocol;
               proxy_set_header Server-Name $server_name;
               proxy_set_header Server-Addr $server_addr;
               proxy_set_header Server-Port $server_port;
               proxy_pass http://swoole;
        }
}

Supervisor config:

cat supervisord.conf
; supervisor config file

[unix_http_server]
file=/var/run/supervisor.sock   ; (the path to the socket file)
chmod=0700                       ; sockef file mode (default 0700)

[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)

loglevel=debug
logfile_backups=5
user=root

; the below 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: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL  for a unix socket

; 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.

[program:horizon]
process_name=%(program_name)s
command=php /home/user/project/artisan horizon
autostart=true
autorestart=true
user=user
stdout_logfile=/home/user/logs/horizon.log
stdout_logfile_maxbytes=10485760
stderr_logfile=/home/user/logs/horizon_error.log
stderr_logfile_maxbytes=10485760
stopwaitsecs=3600

[program:swoole]
process_name=%(program_name)s
command=/home/user/project/bin/laravels start -i
numprocs=1
autostart=true
autorestart=true
startretries=3
umask=122
user=user
stdout_logfile=/home/user/logs/laravels.log
stdout_logfile_maxbytes=10485760
stderr_logfile=/home/user/logs/laravels_error.log
stderr_logfile_maxbytes=10485760
hhxsv5 commented 4 years ago

Swoole is not compatible with Xdebug, try Sdebug.

juslintek commented 4 years ago

@hhxsv5, well this is Sdebug, if you read the issue I've linked, the title might be misleading. :-) I'll rename it. :-)

juber-nunes commented 3 years ago

@hhxsv5 Any update or workaround on this?

juslintek commented 3 years ago

Okay I think I'm about to solve it. Basically need to use yasd extension. And need to run php -e bin/laravels start. And need to do like written here: https://github.com/swoole/yasd#debugging-with-phpstorm-remote-mode and it should work. Will test it throughly to provide 100% working confirmation. If @juber-ivre wants to give a try before me, have a go and let me know, how it went.

juslintek commented 3 years ago

Guess yasd is not working under docker with php 8 and php 7.4, haven't tested with lower versions