Skip to content
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

update mqtt_service systemd unit file to tag logs and give other logg… #623

Merged
merged 1 commit into from
Jan 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
update mqtt_service systemd unit file to tag logs and give other logg…
…ing options
  • Loading branch information
glynhudson committed Jan 6, 2017
commit 5a2055c35638ea304b487686048585f50b578da0
7 changes: 6 additions & 1 deletion docs/RaspberryPi/MQTT.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ sudo systemctl daemon-reload
sudo systemctl enable mqtt_service
```

Start / stop with:
Start / stop / restart with:

```
sudo systemctl start mqtt_input
sudo systemctl stop mqtt_input
sudo systemctl restart mqtt_input
```

View status / log with:
Expand All @@ -66,6 +67,10 @@ View status / log with:

*Where -nX is the number of log lines to view*

Log can be viewed as text and standrd text manipulation tools can be applied:

`sudo journalctl -f -u mqtt_input -o cat | grep emontx`

## Node format

#### emoncms as a publisher
Expand Down
12 changes: 12 additions & 0 deletions scripts/mqtt_input.service
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# VIEW STATUS / LOG
# sudo systemctl status mqtt_input -n50
# where -nX is the number of log lines to view
# sudo journalctl -f -u mqtt_input -o cat | grep emontx

###
#
Expand All @@ -29,15 +30,26 @@
[Unit]
Description=Emoncms MQTT Input Script
After=mosquitto.service mysql.service redis.service
Documentation=https://github.com/emoncms/emoncms/blob/master/docs/RaspberryPi/MQTT.md

[Service]
Type=idle
ExecStart=/usr/bin/php /var/www/emoncms/scripts/phpmqtt_input.php

Uncomment instead of above to use standard log file, else use systemd log
# ExecStart=/usr/bin/php /var/www/emoncms/scripts/phpmqtt_input.php > /var/log/mqtt_input.log 2>&1

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

# Tag things in the log
# View with: sudo journalctl -f -u mqtt_input -o cat
SyslogIdentifier=mqtt_input

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

[Install]
WantedBy=multi-user.target