-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Errors on non-pi systems #80
Comments
Hi, So this is a quick keyboard bash just to list them before I forget and have to rediscover them next time i do this! It appears that convention defines webroot in $emoncms_www from the config.ini file but there are places where this is not honoured. My emoncms webroot is not at /var/www (because this serves another application) its at /srv/dev-disk-by-label-SSD/webroot/emoncms. Now I could create a symlink /var/www/emoncms to point to /srv...etc but... Seeing the option to define it in install/config.ini in $emoncms_www I thought this was the way to go rather than mucking about with symlinks but there are places where this is not honoured eg the service unit files that point back to the .php and .py files that are the services. In emoncms/scripts/services/feedwriter/feedwriter.service:
feedwriter service fails to start unless feeds redis low write mode is enabled. So is this only for SDcard based installs? Do i not need it then? Do I need to install it? In emoncms/scripts/services/service-runner/service-runner.service
In emoncms_core.sh updater:
All for now.. Thanks, Andy |
@andyjbm - it should be better than this. Just to confirm, you edited the config.ini to set the www path and set the EmonScripts/install/emonsd.config.ini Line 6 in 3359f9b
|
This is solved by the use of a drop-in for non-pi users. EmonScripts/install/emoncms_core.sh Line 87 in d03d8e1
It will if the USER is wrong.
Yes Feedwriter, service-runner and emoncms_mqtt all need REDIS - it is a wants in the service file. I think this is the source of your issues as these services are not installed by the installer unless REDIS is installed. EmonScripts/install/emoncms_core.sh Line 78 in d03d8e1
Not according to the docs https://www.freedesktop.org/software/systemd/man/systemd.exec.html#Environment= |
Because the newer 'ini' mechanism is hierarchical, it doesn't need to. In the 'old days' if a new setting was added, the user had to regenerate the
Depends how you reinstall them. Again, if the emonscripts config is correct, I think it is fine as it passes a
That could be a bug. Can you point me to where this may be happening? (I think you are right #96 ) |
@borpin Yes I did all of that. I more or less single stepped through the installer to see what was happening. |
I modified the service-runner.service file with USER=root and it still failed: eg:
It didn't appear to make any difference actually. I came across more examples without quotes than with.
to see what was happening and the file created was always wrapped in single quotes thus 'root'.txt As an aside I would suggest migrating to a user eg emoncms for the services and for emoncms in general which would make it pi agnostic. In hindsight I wish I'd done that rather than setting them up as root. Andy. |
So I don't actually need feedwriter if I don't want low write functionallity but service-runner will still work?
This was actually an upgrade from V9.8 (2017). So nginx, php, Redis were all installed and up.
And saw that /var/www/emoncms/scripts/feedwriter.php also needed redisbuffer[enabled] = true to work.
It wasn't the service unit. See here, this is what stopped me: I think I misunderstood whether I needed feedwriter. I'm guessing I don't now. Andy |
Ok. So I needn't worry about this. |
I was thinking I saw a git pull over the top of the emoncms folder in the update script which will overwrite the now modified service-runner.service file in emoncms/scripts/services/service-runner? |
hardcoded at Lines 90 and 103 in /opt/openenergymonitor/EmonScripts/update/emoncms_core.sh:
EmonScripts/update/emoncms_core.sh Line 90 in 3359f9b
EmonScripts/update/emoncms_core.sh Line 103 in 3359f9b
So as they will be present in the /var/www/emoncms folder but not necessarily required or installed as services they will get installed and started when the update is run. The inistall/config.ini settings are not honoured. Thanks for your help in understanding. |
Happy to accept the PR 😁
Yes and that is deliberate. In general it is a bad idea to edit any service file as there is always a risk a package update will overwrite it. Either create your on drop-in or use Feedwriter is a buffering system that reduces disk writes. It costs nothing to run in reality and probably de-stresses any system.
With what error? I've successfully installed on Debian with a different user but not with a modified www location. |
Ah, did you run the install script with REDIS enabled? It does a number of different things as there are 3 separate bits of REDIS (server, PHP & Python). |
We'll see how much is left of lockdown when I've got this working... You never know! My weakness is github - I don't use it enough. Lots of one off projects. Now how the heck did you post that smiley emoji? ;-)
Indeed. Not come across this situation before. /var/www... seems an unusual place for a service file?? (yeah yeah all PRs appreciated!) And it has hardcoded references. systemctl edit - ok will do it that way.
Ok so worth it then. But just to be clear this is just for feeds and not for service-runner messages? I'm seeing that now.
I will try and reproduce and get back to you.
TBF the different /var/www was the real headache. and moving from /home/pi/data to /var/opt/emoncms was a good step. |
I didn't run the install script directly no. I've mentioned somewhere that this was really an upgrade from V9.8 ish (2017) with a goal of being able to do backup from the gui. It wasn't immediately clear what the dependencies were (I've learned a lot in the last couple of days) - ie backup button in gui, backup_controller.php pushes to redis, service-runner polls redis (there's another bug: emoncms/backup#64 ) which then calls the backup script. I've got it as far as launching a fake backup script so I could validate the paths are all correct. So tomorrow I'll try it for real. |
@borpin
Uncommented the chown command and tried to restart the service.
So the chown command fails but ps -x | grep feedwriter shows the service did start. Andy. |
YAY! Found it. So this line in EmonScripts/install/emoncms_core.sh: EmonScripts/install/emoncms_core.sh Line 99 in 3359f9b
Is where it all went wrong. It creates a drop-in (before I knew what one of those was) . The line in the dropin created by the script looked like this:
With both the double and single quotes.
Once I deleted the Environment line from the dropin with
works and the chown executes, no drop in. Tomorrow I might try adding it to the drop in without any quotes at all and see if that works as well. If there is anything else you'd specifically you'd like me to test? I'm not sure if the issue is the drop in, the fact that it's root, the single quotes or a combination of all three. Andy. |
Initial setup is to create a fork, clone the fork locally and create a new branch for your feature. Then code to your hearts content - VSCode has good integration now for Git.
colon rofl
Those should get changed via the SED command during install to the
Depends what 'this' is - service-runner and emoncms-mqtt are triggered via REDIS messages (as you have worked out).
Great - yes that is what it does 😁
That should work despite the funny quotes - I don't think Are you saying the way the dropin is created by the script is not working? - If so can you open a fresh issue please. To save grief when an update is done, you need to set the service file back to where it was and include a drop-in. Do a |
I didn't see where the /var/www reference in the .service files got changed. Here: And the same for feedwriter.service. Are you saying the installer uses an sed to change the /var/www reference there to $emoncms_www contents? I missed that. I don't think it does. But that would also mean a change to the service file would not be overwritten on an update too? Because sed changed it? The updater would have to recognise an update was ok to do and also have to sed again after the update.
I agree it's not systemd that's fussy, it's the chown command that's fussy. But if you put the literal in the service file thus:
it works but the evaluation of ${USER} to 'root' (incl single quotes) does not.
The dropin creation is working if what it creates is correct. We end up with $[USER} being set to 'root' (incl quotes). But the chown command doesn't like it and doesn't execute. (the /var/log/path ownership is not changed) but the service does start (once both redis and redis low write are enabled). I think the drop in line in the installer here: EmonScripts/install/emoncms_core.sh Line 99 in cff186a
Should look like: echo $'[Service]\nEnvironment="USER=$user"' > feedwriter.conf But I really need to set up another box to test it from scratch as there is only so much I should be doing on this production box really. I can open another issue for this specifically for now?
Yes. Understood now. But what about the change of /var/www path mentioned above? I have to do that. If I git pull then the service file has the wrong path to the executable as I'm not using /var/www... My only solution would be an emoncms symlink in /var/www to where my emoncms folder really is but that then needs hiding from what is using the real /var/www. Could be a solution... But that defeats the effort of $emoncms_www as a reference to the real /var/www if I'm just going to solve it with a symlink. Should/can the change of /var/www path be a drop-in too? What if the names/locations of the feedwriter.php and service-runner.py files change? The drop-in will always override those changes. I'm not convinced this is resolved but this has moved from getting my production system upgraded into development now so I need to get another box spun up to pursue it further. Ironically I have plenty of PIs available but nothing vanilla debian to hand. I'll come back to it with some answers when I'm a bit more prepared. Thanks for your patience so far. Andy. |
You are right, the execution path is hard coded in the service files. I though we had solved that somewhere.
Actually I think an environment variable for the Could you raise a PR for that and a second one for the
Actually, when I went back and looked again it can be one of 3 formats (as you had said).
I'd leave the quotes out altogether. |
The problem is not so much as what systemd allows as what is ultimately being passed to chown and what chown is happy with. The issue appears more to be with chown than the systemd nomenclature although as they say put quotes in, get quotes out.
with quotes however unusual but will fail when it is evaluating essentially the same from ${USER}. Is that systemd or chown being hinky? I've no idea. But either way definitely something hinky going on there as Abby would say.
...and chown and I would agree with you also - because it works. Still not sure on systemd's opinion. I don't think it cares. I'll try with the PR sometime next week when I've got a dev env up and a bit more time. It will be my 1st on github so be patient! A. |
I'm not sure that /var/www is the best place for a service file and its executable in the 1st place? I appreciate how emoncms has evolved from a purely web based implementation and how that location makes for an easy git pull update but moving away from the pi domain SDCard image deployment which you have complete control over to "grown up" platforms which emoncms is surely worthy of I think service files and executables need to be outside of /var/www. (Wherever that should be). /opt? But that is quite an architectural change from the current emoncms deployment from an installer point of view. As I understand it software (debian perspective) that has no dpkg management goes in /opt. But then I'm a windows chap for my sins. And really electronics hardware 1st. So when it comes to linux environment I can tell you what's wrong and how I made it work for me but not necessarily the best practice way to fix it. But I'm keen. ish. What do you think? A. |
Agreed but systemd is doing what it is being asked to do, set the
🤣
You are not going to change that anytime soon! - @TrystanLea It was quite a move to put most of the executable stuff in
That's fine, but this one probably needs to be left alone for now (in terms of exe location) and just fix the www and the USER issues to make it actually work.
No bother, got to start somewhere. DM me or start a thread on the community. |
Hi @borpin, I apologise 1st for another long post but hopefully it is worth it. So my previous install did not have any of the symlinked modules installed. I added the backup module and the postprocess module (in the install/config.ini file) as they looked useful to me. So at first trying to get postprocess to work from the webgui it would just "stop" after the create process button was pressed because (after much faffing) I discovered that the postprocess table was not created in the emoncms mysql database. This is partly my bad because I did not run this line: EmonScripts/install/emoncms_modules.sh Line 52 in cff186a
from the command line. Instead I performed a database update from the webgui admin page. But this did not create the postprocess table because at that point the directory /opt/emoncms/modules/postprocess had ownership root:root whereas running the line 52 above would have updated the database (I trust). Hands up - my fault so far... but I did not know this at this stage. Going back to EmonScripts/install/emoncms_modules.sh (because I ran it as root) I still end up with a folder /opt/emoncms/modules/postprocess symlinked into /var/www that has chown root:root ownership and can't be seen by www-data which is what my nginx and php services are running as. Once I discovered this was the case I went back to the web admin and lo and behold there were the database updates waiting to be committed. Of course now the webgui could see the module directories now I had chowned them www-data:users. So I started to dig a bit into the install process again: Then init.sh calls main.sh which loads the user from config.ini and eventually calls emoncms_modules.sh In emoncms_modules.sh the symlinked modules are git pulled but the ownership of these directories are never modified. So starting here: EmonScripts/install/emoncms_modules.sh Line 19 in cff186a
So in conclusion lots of questions. A. What users would you expect nginx and php to be running as? www-data or pi or something else? B. I will confirm once I'm done with this live system upgrade and have time for dev but I think I'm right in that a fresh install run as root would leave you with /opt/emoncms chowned to the user set in config.ini but modules dir and each modules/module1-module etc dir chowned as the user that ran the ./init.sh C. I'm thinking these should all be accessible to www-data? But that's because that's what my php is executing under. Thanks once more, |
Hi @andyjbm, realised I'd never responded. You are right, the scripts started off from a very 'pi' orientated base - on Ubuntu, I create a user pi and use that! The scripts also expect Apache not nginx and it is unlikely we would modify the scripts to meet that requirement. |
I think this can now be closed. |
Hi @TrystanLea Just installed on an Ubuntu system. had an error because of hardcoded user name so tried again with the user pi created.
1. No log window
2.
Demandshaper not in menuJust realised it has moved 🤦♂
3. Dashboards not imported
4. Cannot create new dashboards
The text was updated successfully, but these errors were encountered: