LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 06-05-2012, 02:37 AM   #1
Ale87zorg
LQ Newbie
 
Registered: Jun 2012
Posts: 10

Rep: Reputation: Disabled
Daemon on Centos


Hi everyone,

I have to run a process as a daemon on a Centos 6 Server; but because Centos doesn't have a daemon tool I have installed this tool from http://libslack.org/daemon/.

Now the problem is that when i run:

# daemon --name koha-zebra-daemon --restart
daemon: fatal: failed to find pid for koha-zebra-daemon: No such file or directory

the daemon tool doesn't find the PID files for the daemon that are located in:
/var/lock/koha/zebradb/biblios/zebrasrv.pid
/var/lock/koha/zebradb/authorities/zebrasrv.pid

It seems that I have to specify in the file "koha-zebra-daemon" where are located the PID files; but I don't know how can I do this.

I copy here the content of the koha-zebra-daemon file located in /etc/init.d:
------------------
#!/bin/bash

# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA

### BEGIN INIT INFO
# Provides: koha-zebra-daemon
# Required-Start: $syslog $remote_fs
# Required-Stop: $syslog $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Zebra server daemon for Koha indexing
### END INIT INFO

USER=koha
GROUP=koha
DBNAME=koha
NAME=koha-zebra-ctl.$DBNAME
LOGDIR=/var/log/koha
ERRLOG=$LOGDIR/koha-zebradaemon.err
STDOUT=$LOGDIR/koha-zebradaemon.log
OUTPUT=$LOGDIR/koha-zebradaemon-output.log
KOHA_CONF=/etc/koha/koha-conf.xml
RUNDIR=/var/run/koha/zebradb
LOCKDIR=/var/lock/koha/zebradb
# you may need to change this depending on where zebrasrv is installed
ZEBRASRV=usr/local/bin/zebrasrv
ZEBRAOPTIONS="-v none,fatal,warn"

test -f $ZEBRASRV || exit 0

OTHERUSER=''
if [[ $EUID -eq 0 ]]; then
OTHERUSER="--user=$USER.$GROUP"
fi

case "$1" in
start)
echo "Starting Zebra Server"

# create run and lock directories if needed;
# /var/run and /var/lock are completely cleared at boot
# on some platforms
if [[ ! -d $RUNDIR ]]; then
umask 022
mkdir -p $RUNDIR
if [[ $EUID -eq 0 ]]; then
chown $USER:$GROUP $RUNDIR
fi
fi
if [[ ! -d $LOCKDIR ]]; then
umask 022
mkdir -p $LOCKDIR
mkdir -p $LOCKDIR/biblios
mkdir -p $LOCKDIR/authorities
if [[ $EUID -eq 0 ]]; then
chown -R $USER:$GROUP $LOCKDIR
fi
fi

daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 $OTHERUSER -- $ZEBRASRV $ZEBRAOPTIONS -f $KOHA_CONF
;;
stop)
echo "Stopping Zebra Server"
daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 $OTHERUSER --stop -- $ZEBRASRV -f $KOHA_CONF
;;
restart)
echo "Restarting the Zebra Server"
daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 $OTHERUSER --restart -- $ZEBRASRV -f $KOHA_CONF
;;
*)
echo "Usage: /etc/init.d/$NAME {start|stop|restart}"
exit 1
;;
esac
---------------
Thanks and Kind Regards
Alessandro
 
Old 06-05-2012, 04:59 AM   #2
maccas17
Member
 
Registered: May 2010
Location: UK
Distribution: RHEL6
Posts: 70

Rep: Reputation: 10
You could just use xinetd (which you can install from CentOS repos) and use it to run and manage your daemon.

An example I found is at:

http://linuxpoison.blogspot.co.uk/20...ice-under.html

Hope this helps.
 
Old 06-05-2012, 05:10 AM   #3
cliffordw
Member
 
Registered: Jan 2012
Location: South Africa
Posts: 281

Rep: Reputation: 118Reputation: 118
Hi there,

I'm not familiar with koha, but from the following comment in your post:

Quote:
Originally Posted by Ale87zorg View Post
# daemon --name koha-zebra-daemon --restart
and these extracts from the init script:
Code:
DBNAME=koha
NAME=koha-zebra-ctl.$DBNAME

      daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 $OTHERUSER -- $ZEBRASRV $ZEBRAOPTIONS -f $KOHA_CONF
It looks like you are using different names for the daemon from the command line & in the script.

To test this possibility, you could try running:
Code:
/etc/init.d/koha-zebra-daemon restart
instead of:
Code:
daemon --name koha-zebra-daemon --restart
 
Old 06-05-2012, 06:46 AM   #4
Ale87zorg
LQ Newbie
 
Registered: Jun 2012
Posts: 10

Original Poster
Rep: Reputation: Disabled
Hi Cliffordw,

thank you for your answer.

Probably you have the reason, in fact if I run from the command line:

----
# /etc/init.d/koha-zebra-daemon restart
Restarting the Zebra Server
daemon: fatal: failed to find pid for koha-zebra-ctl.koha: No such file or directory
----

It gets the real name of the daemon: "koha-zebra-ctl.koha", but however the problem with PID file still remain.

Thanks and Regards
Alessandro
 
Old 06-05-2012, 07:45 AM   #5
Ale87zorg
LQ Newbie
 
Registered: Jun 2012
Posts: 10

Original Poster
Rep: Reputation: Disabled
Smile Solved

Hi everyone,

finally I have solved the iusse:

the problem was in the user and group of the folder interesting in the daemon process.

I have just set the folder (and their files):

/var/log/koha
/var/run/koha
/var/lock/koha

as
#chown -R koha. .


And then run:

#/etc/init.d/koha-zebra-daemon start
Starting Zebra Server

And now the daemon run fine:

# ps aux | grep zebra
koha 9707 0.0 0.0 5524 648 ? S 07:34 0:00 daemon --name=koha-zebra-ctl.koha --errlog=/var/log/koha/koha-zebradaemon.err --stdout=/var/log/koha/koha-zebradaemon.log --output=/var/log/koha/koha-zebradaemon-output.log --verbose=1 --respawn --delay=30 --user=koha.koha -- usr/local/bin/zebrasrv -v none,fatal,warn -f /etc/koha/koha-conf.xml
koha 9725 0.0 0.4 9040 4164 ? S 07:36 0:00 usr/local/bin/zebrasrv -v none,fatal,warn -f /etc/koha/koha-conf.xml
root 9779 0.0 0.0 5476 744 pts/0 S+ 07:45 0:00 grep zebra


Thanks to all for your help and suggestion

Alessandro
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to open a connection to the libvirt management daemon on CentOS 6 ashutosh0084 Linux - Virtualization and Cloud 1 12-26-2011 02:54 AM
Bash script to verify the daemon is working if not, start the daemon kishoreru Linux - Newbie 7 09-23-2009 05:29 AM
Using debian start-stop-daemon on Centos powadha Linux - Software 1 11-02-2008 06:59 AM
Enable daemon to run with service daemon start,etc baddah Programming 6 12-02-2007 06:51 PM
CentOS bootup failure after initializing HAL Daemon dsm Linux - Newbie 0 09-25-2007 02:33 AM


All times are GMT -5. The time now is 11:29 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration