danielolson13 / wink-mqtt

Enable local-control of a rooted Wink Hub with MQTT
MIT License
31 stars 9 forks source link

Service Fails #2

Closed Mdleal closed 8 years ago

Mdleal commented 8 years ago

Are you having issues with the application crashing because the wink is out of memory? Maybe I'm just sending too many messages. I have an Aeon Energy plug that updates every few seconds.

danielolson13 commented 8 years ago

Are you running the latest code? I added a check to limit calls to checking the wink database if a check is already running.

On Mon, Feb 22, 2016 at 2:58 PM Mdleal notifications@github.com wrote:

Are you having issues with the application crashing because the wink is out of memory? Maybe I'm just sending too many messages. I have an Aeon Energy plug that updates every few seconds.

— Reply to this email directly or view it on GitHub https://github.com/danielolson13/wink-mqtt/issues/2.

Mdleal commented 8 years ago

I last updated when you fixed the 2.49 db issuse.

child_process.js:958 throw errnoException(process._errno, 'spawn'); ^ Error: spawn ENOMEM at errnoException (child_process.js:1011:11) at ChildProcess.spawn (child_process.js:958:11) at exports.spawn (child_process.js:746:9) at Object.exports.execFile (child_process.js:628:15) at checkDatabase (/opt/local_control/wink-mqtt/wink-mqtt.js:73:22) at Tail.deviceStatus.(anonymous function) (/opt/local_control/wink-mqtt/wink-mqtt.js:29:9) at checkDatabase (/opt/local_control/wink-mqtt/wink-mqtt.js:73:22) at Tail.deviceStatus.(anonymous function) (/opt/local_control/wink-mqtt/wink-mqtt.js:29:9) at Tail.emit (events.js:95:17) at /opt/local_control/wink-mqtt/node_modules/always-tail/index.js:78:32 at Object.wrapper as oncomplete

Mdleal commented 8 years ago

Just updated my wink-mqtt.js and same issue. Maybe it is my startup script.

!/bin/sh

case "${1}" in start) echo -n "Starting mqtt..." /usr/bin/node /opt/local_control/wink-mqtt/wink-mqtt.js >> /var/log/mqtt.log 2>&1 ;; stop) echo -n "Stopping mqtt..." killall wink-mqtt.js ;; restart) ${0} stop sleep 1 ${0} start ;; *) echo "Usage: $0 [start|stop|restart]" ;; esac

Mdleal commented 8 years ago

I added the following to the startup script. Let's see if that helps. --max_old_space_size=5 --max-stack-size=5 --max_executable_size=5

danielolson13 commented 8 years ago

Let me know if that works. That's how the native local-control node server is started and how I am running my wink-mqtt.js. I do not have a device that sends updates every few seconds, so that may be the difference.

On Tue, Feb 23, 2016 at 1:23 PM Mdleal notifications@github.com wrote:

I added the following to the startup script. Let's see if that helps. --max_old_space_size=5 --max-stack-size=5 --max_executable_size=5

— Reply to this email directly or view it on GitHub https://github.com/danielolson13/wink-mqtt/issues/2#issuecomment-187828873 .

Mdleal commented 8 years ago

Switched things up with the startup process. Used this tutorial and have monit monitoring the service. https://gun.io/blog/tutorial-deploy-node-js-server-with-example/

What is your free memory at (free -m)?

               total         used         free        shared        buffers

Mem: 59 55 3 0 0 -/+ buffers: 55 3 Swap: 0 0 0

danielolson13 commented 8 years ago
         total         used         free       shared      buffers

Mem: 59 55 4 0 0 -/+ buffers: 55 4 Swap: 0 0 0

danielolson13 commented 8 years ago

Are you still having issues? I had issues with spawn running out of memory in the past, but not with the current version. I do not have a zwave device that updates it's status, so that may be the difference. Hitting the checkDatabase function while it was still waiting for the last check to complete causes that error.

Mdleal commented 8 years ago

No issuses since i adjusted my startup script.

danielolson13 commented 8 years ago

Can you share what you added to the /etc/monitrc for monitoring the process?

Mdleal commented 8 years ago

Check out https://www.reddit.com/r/winkhub/comments/474gg7/so_now_that_we_have_local_control_will_we_get_an/

We have been discussing your project. Guy said we can disable AAU and Heartbeat to get more memory. I would also like to disable lutron. Here is my start scrip and monit

/etc/rc.d/init.d/mqtt

!/bin/sh

case "${1}" in start) echo -n "Starting mqtt..."

while ! ping -c 1 -W 1 192.168.1.1; do

  #   echo "Waiting for 192.168.1.1 - network interface might be down..."
  #   sleep 1
  #done
  #sleep 10
  node --max_old_space_size=4  --max_executable_size=4  /opt/local_control/wink-mqtt/wink-mqtt.js 1>>"/var/log/mqtt.log" 2>&1 &
       echo $! > "/var/run/mqtt.pid";
  ;;

stop) echo -n "Stopping mqtt..." killall wink-mqtt.js kill cat /var/run/mqtt.pid ;;

restart) ${0} stop sleep 1 ${0} start ;;

*) echo "Usage: $0 [start|stop|restart]" ;;

esac

/etc/monitrc - at the bottom of the file

check process nodejs with pidfile "/var/run/mqtt.pid" start program = "/etc/rc.d/init.d/mqtt start" stop program = "/etc/rc.d/init.d/mqtt stop"

Mdleal commented 8 years ago

I have 15 free memory with disabling AAU and Heartbeat in /opt/local_control/servers.js

danielolson13 commented 8 years ago

Hmmm, I don't have any more memory freed by removing aau and heartbeat from start in /opt/local-control/server.js and now it take about 3 minutes for my wink to reboot. I'm not having any memory issues, I've been running for 24 hours with the same PID.

Mdleal commented 8 years ago

Changes to server.js. do you still see them running?

heartbeat_port : 8886

, aau_port : 8888

And , start : 'wifi'