Unitech / pm2

Node.js Production Process Manager with a built-in Load Balancer.
https://pm2.keymetrics.io/docs/usage/quick-start/
Other
41.52k stars 2.62k forks source link

out log is not support UTF8? #728

Closed shadow0162 closed 9 years ago

shadow0162 commented 10 years ago

i got this error after start process.

undefined:1 {"type":"log:out","data":"g,web8005g+/e#f*g%\n"} ^ SyntaxError: Unexpected token t Object.parse (native) at Pipe.channel.onread (child_process.js:335:28)

The code is "console.log('监听'+'web8005');

what should i do?

Unitech commented 10 years ago

We should add .setEncoding('utf8'); on all log streams

https://github.com/Unitech/PM2/blob/master/lib/ProcessContainer.js#L110

@soyuka ?

soyuka commented 10 years ago

Nope it is utf8 by default.

I'll check this but I don't think it's encoding relative.

soyuka commented 10 years ago

Are you getting these from pm2-interface events? Or is this from the log stream file?

I could not reproduce this.

shadow0162 commented 10 years ago

After this command exec , out log can get the error.(system on ubuntu 12.04_64 & node 0.10.0) root@5Z:pm2 start GambleServer/index.js { online: true, success: true, pid: 30823, pm2_version: '0.9.4' } PM2 Process launched │ App name │ id │ mode │ PID │ status │ restarted │ uptime │ memory │ watching │ │ index │ 0 │ cluster │ 30831 │ online │ 0 │ 0s │ 15.941 MB │ u nactivated │ Use pm2 desc[ribe] <id> to get more details root@5Z:/projects/BoardGames# undefined:1 {"type":"log:out","data":"h?f%16006\n"} ^ SyntaxError: Unexpected token at Object.parse (native) at Pipe.channel.onread (child_process.js:335:28)

Unitech commented 9 years ago

Could you make a little gist to reproduce the error?

Thanks

shadow0162 commented 9 years ago

Sorry for late. i already passed the bug by updated node version(0.10.0 to 0.10.28).And then it never happen again.