workerman icon indicating copy to clipboard operation
workerman copied to clipboard

How to suppress or send to file all output under Windows for single worker?

Open donbidon opened this issue 2 years ago • 1 comments

Subj. I used fclose(STDOUT); but I think it's wrong way. Thanx.

donbidon avatar Feb 22 '22 16:02 donbidon

Worker man doesn't provide the option to redirect output for windows, but you can do it by changing the code.

https://github.com/walkor/workerman/blob/7370cfc9c09f58ab5f4e9593d23ac6069930a570/Worker.php#L1457-L1459

Change codes

$descriptorspec = array(
    STDIN, STDOUT, STDOUT
);

to

$std_file = 'your/path/of/stdout_file';;
$descriptorspec = array(
    STDIN,
    array('file', $std_file, 'w'), // stdout
    array('file', $std_file, 'w') // stderr
);

walkor avatar Feb 23 '22 02:02 walkor