Comments (15)
https://github.com/walkor/workerman.net/blob/master/applications/Doc3.workerman.net/src/SUMMARY.md
Here is the docs,but only chinese.
Yes, you can get the arguments for your script.
from workerman.
When will english docs be available?
I worked out the API, sort of, with a lot of print_r()
's... but having the actual docs would be helpful.
from workerman.
English document may be available after 2 months.
from workerman.
Okay, sounds good! But maybe you can answer me a little question.
Which callback is used upon client initialization? Like, there is onConnect
and such. But is there a function that is called each time the worker is made, on the worker's end? I saw onWorkerCreate
...but I am not sure if this is called from the main process or the worker process.
from workerman.
Yes, onConnect
will be triggered when new client come.
onWorkerStart
will be triggered when worker is made.
onWorkerStop
will be triggered when worker is down.
And on{...}
is allways called from worker process.
from workerman.
Awesome. What are the arguments given to the various callbacks? Only the worker object or more?
from workerman.
$connection
is the instance of TcpConnection
and $worker
is the instance of Worker
.
Worker's callback and arguments
onWorkerStart($worker)
onWorkerStop($worker)
onConnect($connection)
onMessage($connection, $data)
onClose($connection)
onBufferFull($connection) //Emitted when $connection‘s write buffer becomes full.
onBufferDrain($connection) //Emitted when $connection‘s write buffer becomes empty.
onError($connection, $error_code, $error_msg)
TcpConnection's Api and arguments
send($data) // Send data.
getRemoteIp()
getRemotePort()
close() //Close connection.
pauseRecv() //Pauses the reading of data.
resumeRecv() //Resumes reading.
from workerman.
Very nice! This helps me a lot!
One last thing though. I want to intentionally restart a worker. Currently, I am doing this by sending SIGUSR1
to the process itself: http://git.ingwie.me/ingwie/bird3/blob/master/php-lib/YiiApp.php (See YiiApp::stop()
)
Is there an actual "right" way to relaunch a worker?
Does onClose()
reffer to when the client closes the connection to the worker?
from workerman.
If you start workerman by command php start.php start
, you can restart all workers by command php start.php restart
or php start.php reload
for gracefull restart.
You can also send SIGINT
or SIGUSR1
signal to the main process, then all worker processes will be restart or reload. If you send SIGINT
or SIGUSR1
signal to one worker process, then the worker process will be restart or reload.
Any end closed connection will emitted onClose
.
from workerman.
Is there a way to reload a worker, but keeping its statistics? Reloading a worker also means that the stats for connections and such are reset to 0.
from workerman.
It difficult to do that.
Workerman's reload is restart worker processe(s).When a process exit everything will be destroyed.
Maybe Classkit is useful for what you want, but need a lot of codes to achieve it.
from workerman.
Actually it is not that hard.
Each time a worker is created, use the uniqid() function and save that as a variable. Then offer this very worker a restart function. This restart function should mention to the parent process that it wants to restart and give it it’s unique ID. The master sends a signal to finally stop the worker. Then, the process re-fork()s itself and assigns the previous ID again.
You then can assign this very ID to the entries in the worker table - that way the workers can keep their state.
This is just an diea of mine though!
Kind regards, Ingwie.
from workerman.
For example.
You can't reassign the original connnections to the new worker process, because the connections are closed when original worker process stoped.
Main process dose not hold connnections. Every worker processes hold connections for themselves.
from workerman.
English docs are available. English docs
from workerman.
Awesome work! I just looked through them, they are very nice. :)
from workerman.
Related Issues (20)
- Events uv cant handle stop signall HOT 12
- Logic of worker's reload have mistake - please check HOT 12
- Why i can't connect to my SSE (Server-Sent-Events) server? HOT 5
- Connect to websocket on real server, domain or ip server? HOT 5
- What the best way to use workerman with yii2? HOT 4
- v5为什么还没发布? HOT 1
- How to retrieve cookie from $request parametr if it's a string? HOT 1
- Incorrect parsing of connection headers HOT 4
- Pass user_id to the server when connecting. HOT 2
- AsyncTcpConnection error when using 'wss' HOT 2
- updated swoole event.
- [WSL] 开发环境退出 webman 时出现死循环 HOT 8
- Why sse server sometimes can stop itself and how to prevent it?
- How to run 2 websockets in different classes? HOT 1
- `/src/Protocols/Http.php` `Content-Length` 疑问 HOT 8
- Websocket worker's onMessage doesn't intercept ping requests. HOT 3
- 有的客户端获取count($globalWorker->connections) 有时候是1 HOT 1
- Question: docker and debug/daemon mode HOT 2
- Feature request: openswoole support HOT 1
- Timer::add in master process is impossible ? I think it can be HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from workerman.