AV-Looks
Watching and Wondering

Running Instiki - Best practices

Posted by Andrew Thu, 16 Feb 2006 00:47:00 GMT

Best practices for running Instiki

Initial setup – prerequisites

  1. Download and install Ruby 1.8.2. In all our experience, later versions of Ruby break Instiki. You can download the source from ruby-lang.org . We recommend building from source (tar zxvf, cd to dir, ./configure, make, make install), though you can certainly install ruby with any of the various package managers out there.
  2. Download and install rubygems . tar zxvf the file, cd into the dir, and run `ruby setup.rb`
  3. run `gem install instiki—include-dependencies`. Besides Ruby 1.8.2, the current Instiki (0.10.2) needs Rails 0.13.1, not higher. A very nice thing about gem is that you can have multiple versions of packages, e.g. Rails 1.0.0 and 0.13.1 installed, and different ruby gems and apps just seem to know what they need.

Setting up Apache

# Path to storage – `mkdir storage` in the appropriate location, e.g.
/home/httpd/vhosts/yourdomain.com/rails/storage
# Virtual Host Config – For each instiki domain, you will need to create a vhost.conf file which contains something like
ServerName wiki.yourdomain.com
ProxyPass / http://wiki.yourdomain.com:2501/
ProxyPassReverse / http://wiki.yourdomain.com:2501
where ‘2501’ above is the port on which this particular instance is running. Each Instiki instance (each domain) must have its own port.

Configuring Instiki to run on startup

Create /etc/rc.d/rc.instiki
#!/bin/bash
## Check and Start Instiki servers

LOGFILE="/usr/local/sbin/instikiStatus.txt" 
cat /dev/null > $LOGFILE
date >> $LOGFILE

## List of servers and ports
for instiki in \
"/home/httpd/vhosts/1domain.com/rails/storage 2501" \
"/home/httpd/vhosts/2domain.com/rails/storage 2502" \
"/home/httpd/vhosts/3domain.com/subdomains/wiki/rails/storage 2503" 

do
  set -- $instiki
  if ps aux | grep instiki | grep $1 > /dev/null
    then
      echo "Instiki server at $1 is running on port $2" >> $LOGFILE
    else
      echo "Instiki server at $1 is not running..." >> $LOGFILE
      /usr/local/bin/ruby /usr/local/bin/instiki --port $2 --storage $1 > /dev/null &
      echo "Instiki server at $1 started on port $2" >> $LOGFILE
  fi
done
cat $LOGFILE

Setting up Instiki to run as a service

create /etc/init.d/instiki
#!/bin/bash
#. /etc/rc.d/init.d/functions
PATH=/sbin://bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/b
in:/usr/local/bin
prog=Instiki
proc="bin/instiki" 
startup=/etc/rc.d/rc.instiki
start() {
      echo -n $"Starting $prog: " 
      bash $startup > /dev/null 2>&1
      echo -e "OK";
}
stop() {
      echo -n "Stopping $prog: " 
      `ps auwx | grep $proc|awk '{print $2}'|xargs kill >/dev/null 2>&1`
      echo -e "OK" 
}
restart(){
    echo -n "Stopping $prog: " 
    `ps auwx | grep $proc|awk '{print $2}'|xargs kill >/dev/null 2>&1`
    echo -e "OK" 
    echo -n $"Starting $prog: " 
    bash $startup > /dev/null 2>&1
    echo -e "OK";
}
status(){
    if `pgrep -f $proc 1>/dev/null 2>/dev/null`;
    then echo "$prog is running on `pgrep -f -d , $proc`" 
    else echo "$prog is not running";
    fi
}
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
 restart)
        restart
        ;;
 status)
        status
        ;;
*)
        echo $"Usage: $prog {start|stop|restart|status}" 
        exit 1
esac
Now you are all set, and can run:
service instiki stop|start|restart

Posted in ,  | Tags , , , ,  | no comments | no trackbacks

Comments

Trackbacks

Use the following link to trackback from your own site:
http://avlooks.net/articles/trackback/6

(leave url/email »)

   Comment Markup Help Preview comment