Comment

Comment by Roboprog

Here is my script to create a test instance in about 5 seconds (albeit without any tables define yet, just space for them, with a running server on that space, and an account to create and use the tables in the DB):

(puts tablespace in folder under current directory)

<code>

#!/bin/sh -x

# create and run an empty database

# note: fails miserably if there are spaces in directory names

PGDATA=`pwd`/pgdata

export PGDATA

# make it if not there

mkdir -p $PGDATA

# clean it out if anything there

/bin/rm -rf $PGDATA/*

# set up the database directory layout

initdb

# start the server process

nohup postgres 2>&1 > postgres.log &

sleep 2

# create an empty DB/schema

createdb edrs_test_db

# create a user and password ("demo") to use for connections

psql -d edrs_test_db -c "create user guest password 'guest'"

ps auxww | grep '[p]ostgres'

echo run tail -f postgres.log to monitor database

# vi: nu ai ts=4 sw=4

# * EOF *

</code>

"edrs" is the name of an app - sub in something more applicable. I'm running this on OXS, but should work on Linux as well.

parent Roboprog 11 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton