weewx multi - weewx/weewx GitHub Wiki

How to run multiple instances of WeeWX

There are a few applications where you might want to run more than one instance of WeeWX. You might want to test a new version of WeeWX using the simulator without disrupting data from your weather station. Or you might have more than one weather station from which you would like to collect data. This is how to do it.

You can run any number of WeeWX instances from a single WeeWX installation. However, each WeeWX instance must have its own:

  • configuration file
  • database
  • reports

The instructions vary slightly depending on where your WeeWX configuration file, database, and reports are located.

Multiple weather stations, one WeeWX installation

Let's say that you have two weather stations connected to a single computer, one station is a Davis Vantage Pro installed at a house and the other an Acurite station installed in a paddock. We will identify them as 'house' and 'paddock'.

1. Create the configuration files

The config files may be named whatever you wish; however, keep in mind that the file name stem will be used later with the init script to control each instance and in the log entries. Typically, a self-evident descriptive single word works best. Create one file for each station, say house.conf and paddock.conf. Put these files in the same directory as your original weewx.conf.

For DEB/RPM package installs:

sudo cp /etc/weewx/weewx.conf /etc/weewx/house.conf
sudo cp /etc/weewx/weewx.conf /etc/weewx/paddock.conf

For pip installs:

cp ~/weewx-data/weewx.conf ~/weewx-data/house.conf
cp ~/weewx-data/weewx.conf ~/weewx-data/paddock.conf

For setup.py installs:

sudo cp /home/weewx/weewx.conf /home/weewx/house.conf
sudo cp /home/weewx/weewx.conf /home/weewx/paddock.conf

2. Verify the driver configurations

In each configuration file, ensure that station_type is set correctly.

For example, in house.conf:

[Station]
    ...
    station_type = Vantage
[Vantage]
    ...

and in paddock.conf:

[Station]
    ...
    station_type = Acurite
[Acurite]
    ...

3. Verify the database configurations

In each configuration file, ensure a unique database.

For example, in house.conf:

[Databases]
    [archive_sqlite](/weewx/weewx/wiki/archive_sqlite)
        database_name = house.sdb
        database_type = SQLite

and in paddock.conf:

[Databases]
    [archive_sqlite](/weewx/weewx/wiki/archive_sqlite)
        database_name = paddock.sdb
        database_type = SQLite

4. Verify the report configurations

In each configuration file, ensure that HTML_ROOT is unique.

For example, in house.conf:

[StdReport]
    HTML_ROOT = public_html/house
    ...

and in paddock.conf:

[StdReport]
    HTML_ROOT = public_html/paddock
    ...

5. Configure the startup script

To make the WeeWX instances start when the system boots, you must configure the init system. The following instructions are for Linux systems that use systemd, or for systems that use sysV init scripts. Use the approach that is appropriate for your system.

If you installed WeeWX using a DEB/RPM package, or if you installed using pip and configured WeeWX to run as a daemon, then the systemd unit or sysV init files are already installed. All you have to do is configure them.

Using systemd

Enable each weewxd instance.

sudo systemctl enable weewx@house
sudo systemctl enable weewx@paddock

Using sysV init

In the defaults file /etc/default/weewx file, set the WEEWX_INSTANCES variable to be 'house paddock'.

sudo sed -i 's/^WEEWX_INSTANCES=.*/WEEWX_INSTANCES=\"house paddock\"/' /etc/default/weewx

The file should end up something like this:

WEEWX_PYTHON=python3
WEEWX_BINDIR=/usr/share/weewx
WEEWX_INSTANCES="house paddock"

6. Starting and stopping

Now you can start and stop each instance.

Using systemd

# start each instance
sudo systemctl start weewx@house
sudo systemctl start weewx@paddock

# stop just the paddock
sudo systemctl stop weewx@paddock

# restart only the house instance
sudo systemctl restart weewx@house

# stop all instances
sudo systemctl stop weewx@\*

# get status of all instances
sudo systemctl status weewx@\*

Using sysV init

# check status of every instance
/etc/init.d/weewx status

# start only the paddock instance
sudo /etc/init.d/weewx start paddock

# restart only the paddock instance
sudo /etc/init.d/weewx restart paddock

# stop only the house instance
sudo /etc/init.d/weewx stop house

7. Logging

The log entries for each instance will be uniquely identified. For example, log entries from the house instance will contain weewxd-house and log entries from the paddock instance will be identified by weewxd-paddock. By default, log entries for each instance will be written to the same log file. This can make reading the log file and troubleshooting difficult, especially so if WeeWX log entries are written to the system log. You may wish to consider configuring the logging system to store WeeWX log entries in a separate log file, or even having log entries for each WeeWX instance written to separate files. Refer to the Save WeeWX log messages to a separate file wiki page.