draw134
draw134

Reputation: 1187

Laravel websockets causes python socket error

I got a project installed in ubuntu 18.04 using amazon ec2. I can manually test the websocket server running by websockets:serve command from my project directory. Now that I want to run websockets, the docs said that I need to install supervisor and thats what I did. I created a config file in /etc/supervisor/conf.d/websockets.conf and it has this configuration

[program:websockets]
command=usr/bin/php cd /var/www/html/Inventory/artisan websockets:serve
numprocs=1
autostart=true
autorestart=true
user=laravel-echo

when I do supervisorctl update, what I got is

error: <class 'socket.error'>, [Errno 2] No such file or directory: file: /usr/lib/python2.7/socket.py line: 228

and when i also do sudo supervisorctl status what I get is

unix:///var/run/supervisor.sock no such file

I dont have a supervisor.conf in my /etc directory, the supervisor.conf file is in /etc/supervisor/supervisor.conf just like others encountered.

Do i need to create a supervisor.sock file? or supervisor will create it automatically? Also, my second resort if I cant solve this problem is running websockets by a cronjob. Is that the right thing to do?

Anyways, if you guys got an idea about this please help. Thanks..

Upvotes: 0

Views: 1179

Answers (3)

Dilson Rainov
Dilson Rainov

Reputation: 401

Just remove the "cd" from command

[program:websockets]
command=/usr/bin/php /var/www/html/Inventory/artisan websockets:serve
numprocs=1
autostart=true
autorestart=true
user=laravel-echo

You can find some refences here

Upvotes: 1

Flak
Flak

Reputation: 2670

[program:laravel-websocket]
command=/path/to/your/php /var/www/vhosts/path/to/yout/artisan websockets:serve
autostart=true
autorestart=true
user=your_user
stderr_logfile=/var/log/supervisor-laravel.websocket.err.log
stdout_logfile=/var/log/supervisor-laravel.websocket.out.log

Never run as root

Absolute paths, and of course follow supervisord config guide

Check error logs

Do a netcat/port scan on configured port to be sure you don't miss proxy/firewall rules

ref: https://github.com/beyondcode/laravel-websockets/issues/304#issuecomment-590809667

Upvotes: 1

draw134
draw134

Reputation: 1187

Temporary solution of mine, I just used cron to run websockets:serve once a year.

51 16 9 5 * cd /var/www/html/Inventory/ && php artisan websockets:serve >> /dev/null 2>&1 >> /var/www/html/Inventory/websockets.log

Upvotes: 0

Related Questions