All My Brain Where stuff from my brain lands

October 8, 2007

Gentoo Init Scripts for Cherrypy

A few of the web applications I am hosting/developing are written with TurboGears which uses Cherrypy as its applications server. I have a couple things that need fixed for hosting CherryPy web applications on my Gentoo systems. First, there are no init scripts for CherryPy. Second, I’m running mulitple web applications per machine. I run them as different users with virtual python environments to keep web applications stepping on each others toes.

You can customize the logging for a TurboGears application to have not logging to standard out, but you still have to deal with the python CherryPy process not running as a daemon. I chose rather to run the application in a screen session.

First, a quick script to start my web application in its virtual python environment in my web applications directory.
#!/bin/bash
PATH=/home/<myuser>/bin:$PATH
cd `dirname $0`
./start-<mywebapp>.py prod.cfg

And next, a real simply startup script that starts and stops the application in a screen session.

#!/sbin/runscript
depend() {
need net
}
start() {
su -l $APPUSER -c "screen -S $SESS_NAME -d -m /$APP_DIR/$SCRIPT_NAME"
}
stop() {
su -l $APPUSER -c "screen -S $SESS_NAME -X kill"
}

The variables can go in /etc/conf.d/<app_name> where the <app_name> is the same name as the init.d script. They will automatically be sourced and passed to the init script. For more information on Gentoo init scripts, check here.

October 4, 2007

Upgrading an OLD Gentoo Machine.

Filed under: System Administration — Tags: , , , , , — Dennis @ 11:58 am

I’m in the process of re-installing a pretty old machine with the latest Gentoo. I’ve got a shared NFS directory with portage and all my machines are using a packages directory. After one machine builds something, another machine can simply install the built package.

Here is a portion of the make.conf on each machine.
FEATURES="-distlocks buildpkg"
PKGDIR="/usr/portage/packages/x86"

Well, this particular machine was installed with Glibc 2.3.x. I typed the following to do the upgrade:
emerge -auDvk system
About 1/3 of the way through the upgrade, tar suddenly stopped working:
tar: /lib/libc.so.6: version `GLIBC_2.4' not found (required by tar)
I realized that tar had been upgraded but the glibc was not yet upgraded. To fix the problem, I created a new version of tar on a different system:
USE="static" emerge -av tar # on another machine
scp :/bin/tar /bin/ # from the broken machine.

Off I go, things are working.

October 3, 2007

One way to unemerge lots of unneeded packages on Gentoo Linux

Filed under: System Administration — Tags: , , , , — Dennis @ 12:09 pm

As part of a recent project, I had installed a lot of packages on a separate machine to test my configuration. As is common, with Gentoo, you want to run the following before you actually emerge anything:
emerge -p <package_name>
In this particular case, I noticed the dependency list was pretty long (50 packages to be exact). Instead of going ahead with the emerge, I first recorded the package list to a file for later reference:
emerge -p <package_name> --nospinner > dep.list
Now that I’m done with the project, I can clean up the packages I no longer need like this:
emerge -aC `cat dep.list | grep 'ebuild N' | cut -d ' ' -f 8`
Notice the grep. That is because a couple of the packages were simply upgraded and I don’t know that they aren’t needed. After a quick scan of the resulting list to see what is going to be uninstalled, I let emerge do the rest of the work.

Walla, no more 50 extra packages on that machine.

The Pix xlate command

Filed under: System Administration — Tags: , , — Dennis @ 7:39 am

I’ve recently had cause to change a couple static routings on our Pix 501 Firewall. I’ve done this in the past, but each time, it has resulted in a period of time where the new static mapping doesn’t take effect. Thanks to Jake on the PLUG Mailing list for pointing out to me the xlate command and usage here.

All you need to do is:
clear xlate

EDIT: Derek (same mailing list) suggests the following in order to only clear the one address, so that all the other existing customers are not interrupted.
clear xlate local <e.f.g.h>

October 2, 2007

Using Linux-HA for High Availability with Gentoo and Linux-VServer

In my production setup, I don’t have a load balancer. This may be changed at some point, assuming that we can find one we like for the price we want to purchase it for, but in the mean time, I’ve been inspired to set up a virtual IP address across two machines that each can load balance between my real servers. Inspiration for this project came from this article. I’ll be using Linux-HA to manage the virtual ip address with heartbeat.

(more…)

« Newer Posts

Powered by WordPress

css.php
%d bloggers like this: