Daemon node

43 views
Skip to first unread message

Paul Reed

unread,
Aug 28, 2015, 3:24:46 PM8/28/15
to Node-RED
Has anyone a simple example of using the daemon node to run a php script?
I'm trying to start & keep running a MQTT php class;

sudo php /var/www/emoncms/scripts/phpmqtt_input.php

I've read the node notes and searched the forum but can't find anything which makes a lot of sense at my level!

Paul

Dave C-J

unread,
Aug 28, 2015, 3:42:06 PM8/28/15
to node...@googlegroups.com

Hi Paul,
What does that php script do ?. The daemon node should call it at start/deploy and then send anything it outputs as stdout to the top output, etc. Likewise any payload sent to the node goes to the stdin of the process.

Paul Reed

unread,
Aug 28, 2015, 4:10:55 PM8/28/15
to Node-RED
The script sets up the environment for emoncms to subscribe to topics via phpMQTT - here is a link.
I've attached a debug node to the top right output, put the command as above in the Command box, and every 10 seconds in the debug panel I get.




Dave C-J

unread,
Aug 28, 2015, 4:40:55 PM8/28/15
to node...@googlegroups.com

What happens if you try to run that command from the command prompt (as the same user you are using to run niode-red) ? Or maybe need to path to php fully.

Paul Reed

unread,
Aug 28, 2015, 4:55:56 PM8/28/15
to Node-RED
If I run as the same user from the command prompt (without sudo) the script loads and runs OK, printing the incoming MQTT feed data. If I close SSH the script stops.
Adding the full php path was met with disdain by node-red! it would deploy declaring it 'forbidden'.

Dave C-J

unread,
Aug 28, 2015, 5:47:37 PM8/28/15
to node...@googlegroups.com
Ah...  the command (php) needs to be the only thing in the command...
the /tmp/phpmqtt_input.php is the argument

Inline images 1

Paul Reed

unread,
Aug 28, 2015, 6:08:24 PM8/28/15
to Node-RED
I think that is a step forward, now I get;

...yet the script is not actually running, as the MQTT topics are not updating.


Paul

Dave C-J

unread,
Aug 29, 2015, 7:57:48 AM8/29/15
to node...@googlegroups.com
Paul,

I had a quick look at the php  - around line 32 it tries to create a lock file... Has that already been created an left lying around from some of the previous attempts. It doesn't seem to clean up very well in case of errors.
If I run without sudo on my mac - it fails to even create the file - yet then reports "already running" also... so not sure what it is up to.... and this is standalone... reports the same via Node-RED... over to you :-)

Paul Reed

unread,
Aug 29, 2015, 8:10:42 AM8/29/15
to Node-RED
Thanks for looking Dave. I'm quickly moving to plan B - writing a init file instead!
Reply all
Reply to author
Forward
0 new messages