Skip to content

Commit

Permalink
move serivce runner to services for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
glynhudson committed Nov 17, 2018
1 parent 97feb99 commit 136166b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Systemd unit file for mqtt input script

This comment has been minimized.

Copy link
@borpin

borpin Nov 19, 2018

Contributor

Change this line


# INSTALL:
# sudo cp /var/www/emoncms/scripts/feedwriter.service /etc/systemd/system/feedwriter.service

# sudo ln -s /var/www/emoncms/scripts/services/feedwriter/feedwriter.service /lib/systemd/system

# RUN AT STARTUP
# sudo systemctl daemon-reload

This comment has been minimized.

Copy link
@borpin

borpin Nov 19, 2018

Contributor

daemon-reload is not required unless this file is changed once enable has been used.

Expand All @@ -12,9 +13,14 @@
# sudo systemctl stop feedwriter

# VIEW STATUS / LOG
# If Using Syslog:
# sudo systemctl status feedwriter -n50
# where -nX is the number of log lines to view
# sudo journalctl -f -u feedwriter -o cat | grep emontx
# sudo journalctl -f -u feedwriter
# Otherwise:
# Specify
#StandardOutput=file:/var/log/feedwriter.log
# tail -f /var/log/feedwriter.log

###
#
Expand All @@ -29,28 +35,28 @@

[Unit]
Description=Emoncms MQTT Input Script

This comment has been minimized.

Copy link
@borpin

borpin Nov 19, 2018

Contributor

Change Description

After=mosquitto.service mysql.service redis.service
Wants=mysql.service redis.service
After=mysql.service redis.service
Documentation=https://github.com/emoncms/emoncms/blob/master/docs/RaspberryPi/MQTT.md

This comment has been minimized.

Copy link
@borpin

borpin Nov 19, 2018

Contributor

Change documentation link


# Uncomment this line to use a dedicated log file for StdOut and StdErr.
# NOTE: only works in systemd v236+
# Debain "stretch" includes v232, "buster" includes v239
#StandardOutput=file:/var/log/feedwriter.log

[Service]
Type=idle

This comment has been minimized.

Copy link
@borpin

borpin Nov 19, 2018

Contributor

I am not convinced type idle is the right type. simple is the default and I'm not sure why it should not be so.

ExecStart=/usr/bin/php /var/www/emoncms/scripts/feedwriter.php

This comment has been minimized.

Copy link
@borpin

borpin Nov 19, 2018

Contributor

Does emonpi install the core in /var/www/html/emoncms still?


# Uncomment instead of above to use standard log file, else use systemd log
# Type=forking
# ExecStart=/bin/sh -c '/usr/bin/php /var/www/emoncms/scripts/feedwriter.php 2>&1 > /var/log/feedwriter.log &'

# Restart script if stopped
Restart=always
# Wait 60s before restart
RestartSec=60

# Tag things in the log
# If you want to use the journal instead of the file above, uncomment SyslogIdentifier below
# View with: sudo journalctl -f -u feedwriter -o cat
SyslogIdentifier=feedwriter

# Un-comment to pipe log to syslog
#StandardOutput=syslog

[Install]
WantedBy=multi-user.target
21 changes: 21 additions & 0 deletions scripts/services/install-service-feedwriter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Feedwriter

The feedwriter service writes emoncms feed data to disk when redisbuffer is enabled in settings.php. Feed data is buffered and saved to disk in a more efficent use of block writes than would otherwise be the case, reducing disk wear. This is particularly important on systems running of SD cards.

## Install feedwriter service

If you are not running EmonCMS on Raspbian, modify the .service file to run the service
as an appropriate user. The service is configured to run as the user 'pi' by default.
Install the service using the following commands:
```
sudo ln -s /var/www/emoncms/scripts/services/feedwriter/feedwriter.service /lib/systemd/system
sudo systemctl daemon-reload

This comment has been minimized.

Copy link
@borpin

borpin Nov 19, 2018

Contributor

Not required.

sudo systemctl enable feedwriter.service
sudo systemctl start feedwriter.service
systemctl status feedwriter.service
```

View the log with:
`journalctl -f -u feedwriter`

Tested on Raspiban Stretch

1 comment on commit 136166b

@borpin
Copy link
Contributor

@borpin borpin commented on 136166b Nov 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The readme needs instructions on how to modify existing systems (starting with a check to see if feedwriter is installed) before installing this service file. Any impact on a running system while this is being done shopuld also be explained (like stopping services, data loss etc).

Please sign in to comment.