Another Flat Frog

Welcome to SquashedFrog.Net
Sunday, September 05 2010 @ 02:03 AM BST

Using 1 machine in both dev & production

MythTVBeing a MythTV dev, i need to have a development platform that I can hack around on without affecting my production setup, however this machine has my 2nd tuner, and at times my recording schedule requires the use of the 2nd tuner. So how do i go about using this box as both a development box and as a production box? So a few more details about the setup. My main production system has the first tuner and runs the master backend and MySQL database. This machine is purely a backend machine, and controls all the recordings for the system.

My development machine, when running as part of the production system, is configured to be a slave backend, with the recordings directory NFS mounted off the master backend. When running as my development system it is a full backend / frontend / DB environment, with it's own storage.

So how do I keep the 2 environments separate? Especially when you consider that the DB schema versions are normally different, there are shared libraries that will only work with one version and not the other.

First there cannot be any version of MythTV installed in any of the default locations. Why? Well if things were installed under /usr or /usr/local then the libraries would be under /usr/lib or /usr/local/lib and be picked up by the dynamic library loader. This is BAD! It allows the possibility that the libraries from one version could be picked up by binaries from another version. This will most definitely cause problems.

I build both my 0.21-fixes and SVN head installs from source. This allows me to specify a prefix. For my 0.21 builds i use --prefix=/usr/local/myth-0.21 and for the svn builds i use --prefix=/usr/local/myth-svn. By doing this the libraries and the binaries for each version are separated out into their own area.

How about running those binaries? Attempting to run /usr/local/myth-svn/bin/mythbackend won't work, because the libraries won't be found. Since there are 2 different versions I have 2 different init scripts in /etc/init.d/. One for each version. In each init script I add an entry which tells the dynamic loader which paths to search for libraries, much like editing the path variable to add directories in which to search for executables. The entries are as follows

LD_LIBRARY_PATH=/usr/local/myth-svn/lib:$LD_LIBRARY_PATH
and
LD_LIBRARY_PATH=/usr/local/myth-0.21/lib:$LD_LIBRARY_PATH
This adds the relevant directory to the start of the library search path, and thus the correct libraries are loaded for that backend.

Databases. How does each backend know which database to connect to? The database information is found in the home directory of the user running the backend. Well, more specifically ~/.mythtv/mysql.txt. (See note #1 below)

So for each backend you need a different user account to run it under. I have 2 users, mythtv & dev. Each with their own mysql.txt pointing to different databases One for the production database on the master backend and one for the dev database on the local machine

What about the frontends? The exact same procedure applies. This time I use a wrapper script that lives in /usr/local/bin. This is so I can run either frontend without needing to specify the path. The wrapper script is as follows.

#!/bin/sh

PATH=/usr/local/myth-svn/bin:$PATH
LD_LIBRARY_PATH=/usr/local/myth-svn/lib:$LD_LIBRARY_PATH

export PATH LD_LIBRARY_PATH

exec /usr/local/myth-svn/bin/mythfrontend $@
Since I use the one account for running both production and dev frontends, i make extensive use of the -p flag for the frontend. This tells it to ignore the saved settings and ask for new information. So I run /usr/local/bin/mythfrontend-0.21 -p, and it'll ask me my language, and then find the production backend via upnp, which I then use for watching my recorded programs. If i'm developing, then i just run /usr/local/bin/mythfrontend-svn which is setup to connect to the local development environment. I do it this way since if I forget to specify -p, the 0.21 frontend will just complain that the backend is newer than what it knows about. If I were to do it the otherway around, and accidently run the svn frontend, and then blindly answer a few questions, before I know it, the production database will be updated to svn, and then it'll be broken. Anyway, that's the idea behind running both production & development environments on a single machine.

Note #1. Someone pointed out to me about a little known environment variable MYTHCONFDIR. MYTHCONFDIR specifies which directory to hold the configuration file, so for my production frontend and backend, i've added the following to the wrapper scripts

MYTHCONFDIR=$HOME/.mythtv-prod/
The first time you run the frontend you will still need to specify -p unless you plan to hand populate the config files! But at least you can then save the information and it gets put into the MYTHCONFDIR and thus stays separate from my development configuration.

Trackback

Trackback URL for this entry: http://www.squashedfrog.net/trackback.php?id=20080615193047206

Here's what others have to say about 'Using 1 machine in both dev & production':

vakantie in egypte from vakantie in egypte
De mooiste vakantie aanbiedingen voor egypte [read more]
Tracked on Wednesday, January 06 2010 @ 09:42 PM GMT

Using 1 machine in both dev & production | 0 comments | Create New Account
The following comments are owned by whomever posted them. This site is not responsible for what they say.