EmonScript install issue: demandshaper Activating Auto-restart

I’ve just done a fresh install on Ubuntu 20.04 LTS in a VM using the instructions here: EmonScripts/readme.md at stable · openenergymonitor/EmonScripts · GitHub

I tweaked the config.ini with an appropritate user/hostname and set emonSD_pi_env=0. It mostly seemed happy apart from the Admin page saying: demandshaper Activating Auto-restart

After a quick look at the logs:

:~$ systemctl status demandshaper.service
● demandshaper.service - Emoncms Demandshaper service
     Loaded: loaded (/lib/systemd/system/demandshaper.service; enabled; vendor preset: enabled)
    Drop-In: /etc/systemd/system/demandshaper.service.d
             └─override.conf
     Active: activating (auto-restart) (Result: exit-code) since Sun 2021-05-02 11:17:20 UTC; 3s ago
       Docs: https://github.com/emoncms/demandshaper/blob/master/readme.md
    Process: 5842 ExecStart=/usr/bin/php /opt/emoncms/modules/demandshaper/demandshaper_run.php (code=exited, status=217/USER)
   Main PID: 5842 (code=exited, status=217/USER)

It’s trying to use the user ‘pi’ which doesn’t exist on my system.

If others need to fix this, try:

sudo systemctl edit demandshaper.service

Add the following to the file - I’d suggest using the user set in the config.ini:

[Service]
User=user_who_exists

Then run:

sudo systemctl daemon-reload
sudo systemctl restart demandshaper.service

Most of this info is spread across various other posts in the forum but I wanted to add a concise version so hopefully google will be able to find this in the future :slight_smile:

Is it worth adding to the documentation or having the install scripts automatically create the override file? I’m not sure how popular the EmonScript install route is…

I though we had done this for Debian installs. Perhaps the Demandshaper service file slipped through.

Yes so we do for service-runner (and for other service files IIRC).

The deman shaper service firstly does not follow the convention of other serfviices and use a linked service file

Secondly it does not account fo a different user.

I have raised an issue but on the basis the first issue has never been resolved in 18 months, don’t hold your breath.

It looks like a drop in is being created, just not configured correctly :frowning:

That’s my bad, the log snippet was from after I’d fixed it…

Recreated a VM and started from scratch, the original output should have been:

systemctl status demandshaper.service
● demandshaper.service - Emoncms Demandshaper service
     Loaded: loaded (/lib/systemd/system/demandshaper.service; enabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Mon 2021-05-03 18:42:14 UTC; 9s ago
       Docs: https://github.com/emoncms/demandshaper/blob/master/readme.md
    Process: 30356 ExecStart=/usr/bin/php /opt/emoncms/modules/demandshaper/demandshaper_run.php (code=exited, status=217/USER)
   Main PID: 30356 (code=exited, status=217/USER)

I’m happy to try merging the service-runner stuff into the demand-shaper installer and submitting a PR if it’s helpful?

It’s certainly not a major issue but I just wanted to flag it as others might hit it :slight_smile:

Go for it, but as I say, don’t hold your breath waiting for it to be merged.

True, but time to fix is irritating…