enable/configure redis and swiftmailer + emonhub not start at boot

I reinstalled emoncms using this link:

https://github.com/lafrech/emoncms_emoncms/blob/master/docs/RaspberryPi/...

I'm at 9.4 on Jessie OS on an RPI3. 

I noticed that there was a step to install redis and swittmailer but they aren't configured. 

I've searched the forum and found some info but not much, especially for 9.4.

Instructions for enabling and configuring them would be helpful.

Also, emonhub is not starting on reboot. Something is wrong with the service command.

service emonhub status

gives:

 emonhub.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)

but /etc/init.d/emonhub status gives

[ ok ] Checking OpenEnergyMonitor emonHub: emonhub process is running.

Clearly as I'm getting the feed data in emoncms, emonhub is working. What's are things to check?

Thanks,

billvolz's picture

Re: enable/configure redis and swiftmailer + emonhub not start at boot

The redis issue seems resolved - just had to enable it in settings.php

The Swiftmail issue is still there. Emoncms cannot find the swiftmail code. The log file shows this:

ERROR|email.php|check() Could not find SwiftMailer, email functions are ignored.

And the emonhub service problem is still with me.

Any help or pointers would be appreciated.

billvolz's picture

Re: enable/configure redis and swiftmailer + emonhub not start at boot

Ok I figured out Swift - in the /var/www/emoncms/Lib/email.php I had to change the path to the location of swift_require.php, in this case /usr/share/php.

I also had to set the parameters for sending email for the smtp_email_settings in settings.php. Works fine now.

It would have been far easier if you'd send mail via the mail command - almost eveyone has that installed. A simple system() command with the mail command would have worked just fine.

But what I'm really after is to get an email notice if I don't get an update from emonhub in some specified period, say 60 seconds.My understanding is the Events module is supposed to be able to do that, but it's not being maintained.

pb66's picture

Re: enable/configure redis and swiftmailer + emonhub not start at boot

The event module isn't supported anymore, but there is the beginnings of a replacement built into the core of emoncms now. There is an event process that can email you based on various criteria defined using the logic processes introduced by chaveiro.

You won't be able to "get an email notice if I don't get an update from emonhub in some specified period" per se, as emoncms doesn't log the origin. But you can set it up for any/all of the inputs arriving from emonhub, which is probably what you want.

Paul

billvolz's picture

Re: enable/configure redis and swiftmailer + emonhub not start at boot

Where is this event process in the code? I'd like to take a look at it.

And I really do want to be notified if emonhub doesn't send any data. I'm not that interested in the data itself, just that I hadn't gotten any recently. It appears that emonhub init.d service scripts are not compatible with Jessie systemd scripts - it does not start upon boot but I can start it manually. Yes, I've enabled it with update-rc.d.

The receiver and emontx are separated by 50 feet and several walls and a floor. When I moved the Raspberry to it's current location in a closet downstairs I was getting intermittent messages until I reoriented the antenna which gave me an additional 10dB of signal. If it drops out again I want to know.

pb66's picture

Re: enable/configure redis and swiftmailer + emonhub not start at boot

The eventp module is in the "Modules" directory of emoncms.

Emonhub is only supposed to forward the data passed to it. If no data is passed to emonhub, it cannot forward anything, so monitoring emonhub isn't the solution. The absence of data arriving from the emonTx is what you need to be alerted to, and that can be easily achieved by using the eventp process. This will alert you if the RF packets stop being forwarded by emonhub, whether that be due to emonhub not starting, or because transmissions have dropped out.

The init script is currently the only supported way of starting emonhub. The "init.d" method is supported in Jessie, as the system.d method is backwards compatible. It's used in the emonhub installer script, the OEM emonSD SDcard image, and it's the tried and tested method recommended in the install guides. I have used it myself.

The only 2 cases I can recall that emonhub wouldn't start correctly at boot both came from the install scripts being run as root rather than user pi, the specific reason was never confirmed as those users then chose to reinstall using the user pi.

I suspect, but cannot be sure, that it may be the case here too, since all your quoted commands are absent of any use of "sudo", The link you provide is to a clone of the original "docs" and has not been updated for some time (9th of Dec 2015 for the docs dir). Whilst I do not think there have been any significant changes in that time, I don't know why you wouldn't be using the official and up to date version. Regardless, I have just checked and the same line is used to install emonhub. It references the homedir which if you did run as a different user, will be different.

I suspect the files may not be where they are expected to be, hence the "Loaded: not-found (Reason: No such file or directory)". To get emonhub to (very reliably) start at boot, you can either reinstall as intended, or perhaps just locate the emonhub directory and try editing /etc/default/emonhub so the init script can find the files or move the emonhub dir to /home/pi/. If this is not the case, it could be a permissions issue. Did you use the installer or create the emonhub system user?

Paul

billvolz's picture

Re: enable/configure redis and swiftmailer + emonhub not start at boot

I uninstalled emonhub. Reinstalled as user pi using this command from the latest install page.

git clone https://github.com/emonhub/dev-emonhub.git ~/dev-emonhub && ~/dev-emonhub/install
 

rebooted and emonhub did not start. I tried to start as user pi and it said I needed to be root to start it. service emonhub start failed again as root. but /etc/init.d/emonhub start worked. The link in /etc/init.d/emonhub is owned by root while the file it points to is owned by pi.

pb66's picture

Re: enable/configure redis and swiftmailer + emonhub not start at boot

You don't need to BE root, using "sudo" elevates the user pi to have root privileges. I can only assume there was something left from the failed install that has thwarted this latest attempt, I think you will need to look at the installer script and step through it, making sure each part is in place with the correct permissions. so few users have had any sort of trouble with the installer that this is not really a scenario I have off-hand experience of I'm afraid.

Paul

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.