Psuedocode for server management scripts

By epukinsk

Along the lines of my post on the Forkolator blog on how to set up the server architecture, I’ve written out some pseudocode for scripts that I think would handle the mongrel servers and the nginx load balancer properly:

% start_nginx
get all mongrels from database
create nginx conf
start nginx

% start_mongrels testproject production 2
mongrel start get_a_free_port()
insert mongrel
pid=278112
port=8004
servername=testproject.forkolator.org
app=testproject
environment=production
mongrel start get_a_free_port()
insert mongrel …
mark server for refresh

% start_mongrels testproject development 1

% reload_nginx (runs as a daemon)
get all mongrels from database
create nginx conf
reload nginx conf

% stop_mongrels testproject production
find the mongrel processes
kill them
remove them from the database
mark the server for refresh

Leave a Reply