MX on Linux: Difference between revisions

1,042 bytes added ,  22:23, 29 April 2022
m
No edit summary
Line 407: Line 407:
Look at the <non-Wiki>[Service]</non-wiki> part of the file quoted above.
Look at the <non-Wiki>[Service]</non-wiki> part of the file quoted above.


This states Cumulus should use root for both the user it runs under and for the group permisisons it uses. If you have the technical expertise, you might choose to run MX in a different user, if your weather station type allows MX to run in a different user. If so, replace the "root" inits two locations.
This states Cumulus should use root for both the user it runs under and for the group permissions it uses. If you have the technical expertise, you might choose to run MX in a different user, if your weather station type allows MX to run in a different user. If so, replace the "root" inits two locations.


Look at the rest of the file, the <non-Wiki>[Unit]</non-wiki> part.
Look at the rest of the file, the <non-Wiki>[Unit]</non-wiki> part.
Line 415: Line 415:
For release 3.15.1 build 3170 (19 March 2022) onwards: you will see an extra line <code>Wants=network-online.target</code>
For release 3.15.1 build 3170 (19 March 2022) onwards: you will see an extra line <code>Wants=network-online.target</code>


You might consider adding a blank line after <code>Documentation=https://cumuluswiki.org/a/Main_Page</code>
If you are a technical user, you might decide to edit this, you have to decide what is needed in your context.


In that blank line, type <code>Requires= time-sync.target  local-fs.target</code>.
As an example, add a blank line after <code>Documentation=https://cumuluswiki.org/a/Main_Page</code> and in that blank line, type <code>Requires= time-sync.target  local-fs.target</code>. A standard raspberry pi computer does not have a real-time clock, so when you switch it on, the clock just continues from whatever the time was when it was switched off. If the computer has online access, then it can look up the correct time online and adjust its clock.  We don't want MX to start until after the time has been synced, and we want the local file-system to be ready for MX to update/store files. The example extra line ensures (Requires) these events have happened before MX can start.
 
A standard raspberry pi computer does not have a real-time clock, so when you switch it on, the clock just continues from whatever the time was when it was switched off. If the computer has online access, then it can look up the correct time online and adjust its clock.  We don't want MX to start until after the time has been synced, and we want the local file-system to be ready for MX to update/store files. THe extra line ensures (Requires) these events have happened before MX can start.




Line 425: Line 423:
# Entries
# Entries
#* The terminology "After" tells "systemd" that what is named can be started after MX, in this case it does not guarantee that the network service (to send data to a remote web server) will be started
#* The terminology "After" tells "systemd" that what is named can be started after MX, in this case it does not guarantee that the network service (to send data to a remote web server) will be started
#* The terminology "Wants" tells "systemd" that what is named is wanted now, i.e. try to start before MX, but start MX even if the starting of the network service fails.
#* The terminology "Wants" tells "systemd" that what is named is wanted now, i.e. try to start before MX, but still start MX even if the starting of the network service fails.
#* The terminology ''Requires'' tells  "systemd" that the "cumulusmx" service should not be started until the services specified on that line have successfully started
#* The terminology ''Requires'' tells  "systemd" that the "cumulusmx" service should not be started until the services specified on that line have successfully started
#*# The '''local-fs.target''' specifies that the ''cumulusmx'' service requires the file service to have started, i.e. checks your computer can read files before it attempts to start the ''cumulusmx'' service
#*# The '''local-fs.target''' specifies that the ''cumulusmx'' service requires the file service to have started, i.e. checks your computer can read files before it attempts to start the ''cumulusmx'' service
Line 431: Line 429:
#*#* If you are using a weather station type that does not time-stamp the readings it supplies to a Raspberry Pi, adding that target reference is important
#*#* If you are using a weather station type that does not time-stamp the readings it supplies to a Raspberry Pi, adding that target reference is important
#*#* A standard RPi does not include a real time clock chip (it can be added via connections available), therefore when the RPi boots it initially uses a dummy clock, and this sets the time to when the RPi was last running.
#*#* A standard RPi does not include a real time clock chip (it can be added via connections available), therefore when the RPi boots it initially uses a dummy clock, and this sets the time to when the RPi was last running.
#*#* That means without this target being included, a newly booted-up RPi will tell Cumulus MX the time is just after when the computer was shut down, that might be very different to the true current time. It means your Cumulus MX on restarting will skip the catch-up of historic data (should your weather station settings make that available). Some measurements will then get logged against the wrong time.
#*#* That means without this target being included, a newly booted-up RPi will tell Cumulus MX the time is just after when the computer was shut down, that might be very different to the true current time. It means your Cumulus MX on restarting will skip the catch-up of historic data (should your weather station settings make that available). Subsequent measurements will then get logged against the wrong time.
#*#* When the Raspberry Pi does do a time-sync, the time will suddenly jump, this is serious if this means the "rollover" time has been skipped over, as it implies the "dayfile.txt" will miss a line, and many measurements will be logged to wrong day.
#*#* When the Raspberry Pi does do a time-sync, the time will suddenly jump, this is serious if this means the "rollover" time has been skipped over, as it implies the "dayfile.txt" will miss a line, and many measurements will be logged to wrong day.


''Don't forget to save the file under a new name, and copy it as instructed in previous subsection.''
''Don't forget to save the file under a new name, and copy it as instructed in previous subsection.''
===Commands to start, stop, or restart (stop and start in one command) MX as a service===
You will need to start (or restart) MX after you have defined (or redefined) the service as instructed above.  The full set of commands to use with this service are at [[Raspberry_Pi_Image#systemctl_commands|systemctl_commands]], here I simply repeat the basic commands that can be used with any service (start, stop, and restart).
In all these commands, '''just replace [service_name] with ''cumulusmx''''' (or enter the name of another service).
* sudo systemctl start [service_name]
* sudo systemctl stop [service_name]
* sudo systemctl restart [service_name]
If you want MX to automatically start when your Linux computer is booted, just type <code>sudo systemctl enable [service_name]</code> once, and it will be activated on each reboot.  Change the "enable" into "disable" if you don't want an automatic restart.
5,838

edits