DNS

Running apache2 under daemontools

Sunday, 21 March 2010 20:58
Prerequisite: Debian 5.0, apache2

mkdir -m 1755 /var/service/apache2
mkdir -p -m 755 /var/service/apache2/log
cd /var/service/apache2

vim run

#!/bin/sh
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
export APACHE_PID_FILE=/var/run/apache2.pid
exec /usr/sbin/apache2 -DNO_DETACH

chmod 755 run
cd log
wget -O run
http://qmail.jms1.net/scripts/service-any-log-run
chmod 755 run

Stop the startup script:
/etc/init.d/apache2 stop
sysv-rc-conf

The following commands will create the symbolic links needed to start the service.

ln -s /var/service/apache2 /service/
sleep 5
svstat /service/apache2 /service/apache2/log

Running tomcat under daemontools

Friday, 29 January 2010 13:33
There are no translations available.

Prerequisite: tomcat6

Adding system users:

useradd tomcat -g nogroup -d /java/tomcat6/ -s /bin/false -p’*’ -r
useradd tomcatlog -g nogroup -d /tmp -s /bin/false -p’*’ -r

Change the ownership of the directories for running tomcat as unpriviledged user, tomcat:
cd /java/tomcat
chown -R tomcat webapps temp logs work conf

Creating directories

mkdir -p /var/service/
cd /var/service/
mkdir -m 1755 tomcat
cd tomcat
vim run

#!/bin/sh
exec 2>&1
export JAVA_HOME=/usr/lib/jvm/java-6-sun
export JAVA_OPTS=”-Xmx1024M -Xms256M -server”
export TOMCAT_HOME=/java/tomcat6
exec setuidgid tomcat ${TOMCAT_HOME}/bin/catalina.sh run

chmod 755 run
mkdir -m 755 log
chown tomcatlog:nogroup log
cd log
vim run

#!/bin/sh
exec env – PATH=”/usr/local/bin:/usr/bin:/bin” \
setuidgid tomcatlog multilog t n1024 s1048576 ./main \
‘-*’ ‘+*ver: status:*’ =lstatus
chmod 755 run

/etc/init.d/tomcat stop

ln -s /var/service/tomcat /service/tomcat
sleep 5
svstat /service/tomcat/ /service/tomcat/log/

Running Postfix From Daemontools

NOTE: all links in this document refer to external sites which are beyond my control. The documents linked retain the copyright of their respective authors. I disclaim all liabilites for the content presented on the other sites.

Introduction

Postfix is a modular, high-performance and relatively secure mail transport agent for Unix written and maintained by Wietse Z. Venema. It is aimed as replacement for sendmail and tries to mimic its user-visible behaviour closely.

Daemontools is a collection of tiny useful tools that monitor and manage services (daemons) written by Daniel J. Bernstein. If you’re familiar with SysV init and inittab, daemontools do a similar job, but do not have a notion of run levels, but are purely service oriented.

Postfix is usually run from your system startup files, either from a rc file (BSD, some Linux variants) or via SysV-style init (SysV and some other Linux variants). Although Postfix’ master process has proven reliable on a couple of machines in over two years’ time, you may want to start Postfix from daemontools.

Setting up a/servicedirectory entry for Postfix

I’m assuming that you have already installed daemontools as written in Dan’s document. Make sure svscan is started properly at reboot time and it is running before you do the following.

Then, to start Postfix from daemontools, do the following:

  1. Create a directory where you want your run file in. Example:
  2. Create a file /etc/postfix/service/runwhich contains the following (you may want to adjust the PATH to your local needs):
  3. Make this script executable:
  4. Make a symlink into /service:

Notes

  • If postfix has been started outside of daemontools, postfix stop is invoked before postfix is started. This makes sure you can control Postfix with svc. It may however interrupt service for a couple of seconds.
  • svscan will start Postfix in a few seconds’ time.
  • You cannotusepostfix stop,postfix drainandpostfix startto manage Postfix. In case you stop Postfix this way, daemontools will think Postfix has crashed and restart it. If you start Postfix this way, it will either be refused because svscan already started Postfix or, if svscan is started later, supervise will loop and Postfix is not supervised. Also see below.
  • You canusepostfix flushandpostfix checkalthough the latter is done automatically before startup as well.
  • You canusepostfix reloadsafely.
  • To stopPostfix, use:svc -d /service/postfixmnemonic: -d for down
  • To startPostfix, use:svc -u /service/postfixmnemonic: -u for up

http://webdesignledger.com/wp-content/uploads/2010/02/workstations_15.jpg

I know there are others, but this is mine.   I always forget how-to change the default installation path with his software, until of course it’s too late and then I get to re-do it.

Need daemontools, ucspi-tcp, and djbdns source code.

 

Create a working directory

$ mkdir ~/working  && cd ~/working

Grab src code

$ wget http://cr.yp.to/djbdns/djbdns-1.05.tar.gz

$ wget http://cr.yp.to/daemontools/daemontools-0.76.tar.gz
$ wget http://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz

1).  First install daemontools, now if you have never installed anything from David Bernstein, his approach, may seem a little different than what you are normally used to with ./configure; make; make install.  There might be a easy approach to moving this somewhere else but I have found that when I do..it sometimes comes back to bite me.  So for daemontools, I leave it defaulted even thought it still drives me nuts everytime..

Create a /package directory: