oncesk / yii-node-socket

66 stars 46 forks source link

How to restart node-socket automatically #63

Closed paulobrandit closed 9 years ago

paulobrandit commented 9 years ago

Hello. I've deployed node-socket on my client's web application. Everything was running smoothly during 3 months until today. My client called me and told me something was broken. I went to check and noticed the service was down. I checked the node-socket logs but couldn't find any exception. So i started the server again.

First, I really would like to know your suggestion for auto-starting node-socket automatically if something goes wrong. The webapp totally depends on it and it's an huge pain if the service suddenly brokes and my client can't use the app.

Second, there's any other place with nodejs logs besides the protected/runtime/socket-transport.server.log ?

Appreciated.

oncesk commented 9 years ago

Hi,

First: You can create cron task which can check availability of port which you use in node socket, its simple, you can fork yii-node-socket and create method in https://github.com/oncesk/yii-node-socket/blob/master/lib/php/NodeSocketCommand.php like whatchProcess and in it you can use internall methods for checking and starting server if it is down After that set up it in crontab, run every minut or 5 minutes or etc, only run it with yii console script

Other way is using tool like supervisord.

Second: Yes of course you can change default log file path, set it up into yii config files in component configuration, property called socketLogFile

You can choose any place, but do not forgot about directory permissions, folder should has write access for user from which server starts

For changing permissions use chmod command

Отправлено с моего Xiaomi

Сообщение от "paulobrandit notifications@github.com":

Hello. I've deployed node-socket on my client's web application. Everything was running smoothly during 3 months until today. My client called me and told me something was broken. I went to check and noticed the service was down. I checked the node-socket logs but couldn't find any exception. So i started the server again.

First, I really would like to know your suggestion for auto-starting node-socket automatically if something goes wrong. The webapp totally depends on it and it's an huge pain if the service suddenly brokes and my client can't use the app.

Second, there's any other place with nodejs logs besides the protected/runtime/socket-transport.server.log ?

Appreciated.

— Reply to this email directly or view it on GitHub.

paulobrandit commented 9 years ago

Hi once again oncesk, thank you so much for the fast answer!

The first idea seems quite cool, I just don't know how to check node-socket server availability. Can you please help me on that?

About the logs, it's possible to add the timestamp for each trace? Also, I guess when there are errors, they aren't being traced.

Cheers.

oncesk commented 9 years ago

If you create additional method in NodeSocketCommand like

public function actionProcessWatchdog() { if(!$this->isInProgress()) { $this->actionStart(); } }

And from console

./yii node-socket/processWatchdog

Something like that or console commands

$> netstat -tulpn | grep 3001

If have result process alive

3001 - port of nodejs

$> pgrep node

Will show you pids of all nodejs proceses which are ran on you system

Отправлено с моего Xiaomi

Сообщение от "paulobrandit notifications@github.com":

Hi once again oncesk, thank you so much for the fast answer!

The first idea seems quite cool, I just don't know how to check node-socket server availability. Can you please help me on that?

About the logs, it's possible to add the timestamp for each trace? Also, I guess when there are errors, they aren't being traced.

Cheers.

— Reply to this email directly or view it on GitHub.

paulobrandit commented 9 years ago

so isInProgress tells me if the service is running right? Perfect, that will totally fit my needs.

Very very appreciated with your help!

oncesk commented 9 years ago

Yes ;)

Отправлено с моего Xiaomi

Сообщение от "paulobrandit notifications@github.com":

so isInProgress tells me if the service is running right? Perfect, that will totally fit my needs.

Very very appreciated with your help!

— Reply to this email directly or view it on GitHub.