cygnus service not starting as a service - linux

I have installed cygnus using RPMs on my CentOS 7.0 , but I can't started as service:
[centos#cygnus-mongo ~]$ sudo service cygnus start
Starting cygnus (via systemctl): Job for cygnus.service failed. See 'systemctl status cygnus.service' and 'journalctl -xn' for details.
[FAILED]
Here is the errors log:
[centos#cygnus-mongo ~]$ sudo systemctl status cygnus.service
cygnus.service - SYSV: cygnus
Loaded: loaded (/etc/rc.d/init.d/cygnus)
Active: failed (Result: exit-code) since Tue 2016-02-23 07:09:48 UTC; 18s ago
Process: 1184 ExecStart=/etc/rc.d/init.d/cygnus start (code=exited, status=1/FAILURE)
Feb 23 07:09:46 cygnus-mongo.novalocal systemd[1]: Starting SYSV: cygnus...
Feb 23 07:09:46 cygnus-mongo.novalocal su[1189]: (to cygnus) root on none
Feb 23 07:09:46 cygnus-mongo.novalocal cygnus[1184]: Starting Cygnus mongo... bash: /var/run/cygnus/cygnus_mongo.pid: No such file or directory
Feb 23 07:09:46 cygnus-mongo.novalocal cygnus[1184]: bash: /var/log/cygnus//var/log/cygnus/cygnus.log: No such file or directory
Feb 23 07:09:48 cygnus-mongo.novalocal cygnus[1184]: cat: /var/run/cygnus/cygnus_mongo.pid: No such file or directory
Feb 23 07:09:48 cygnus-mongo.novalocal cygnus[1184]: [FAILED]
Feb 23 07:09:48 cygnus-mongo.novalocal cygnus[1184]: rm: cannot remove ‘/var/run/cygnus/cygnus_mongo.pid’: No such file or directory
Feb 23 07:09:48 cygnus-mongo.novalocal systemd[1]: cygnus.service: control process exited, code=exited status=1
Feb 23 07:09:48 cygnus-mongo.novalocal systemd[1]: Failed to start SYSV: cygnus.
Feb 23 07:09:48 cygnus-mongo.novalocal systemd[1]: Unit cygnus.service entered failed state.
[centos#cygnus-mongo ~]$ sudo journalctl -xn
-- Logs begin at Tue 2016-02-23 07:08:59 UTC, end at Tue 2016-02-23 07:10:57 UTC. --
Feb 23 07:10:33 cygnus-mongo.novalocal systemd[1]: Dependency failed for /mnt.
-- Subject: Unit mnt.mount has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mnt.mount has failed.
--
-- The result is dependency.
Feb 23 07:10:33 cygnus-mongo.novalocal systemd[1]: Dependency failed for File System Check on /dev/vdb.
-- Subject: Unit systemd-fsck#dev-vdb.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit systemd-fsck#dev-vdb.service has failed.
--
-- The result is dependency.
Feb 23 07:10:33 cygnus-mongo.novalocal systemd[1]: Startup finished in 1.659s (kernel) + 2.841s (initrd) + 1min 31.190s (userspace) = 1min 35.691s.
-- Subject: System start-up is now complete
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- All system services necessary queued for starting at boot have been
-- successfully started. Note that this does not mean that the machine is
-- now idle as services might still be busy with completing start-up.
--
-- Kernel start-up required 1659184 microseconds.
--
-- Initial RAM disk start-up required 2841741 microseconds.
--
-- Userspace start-up required 91190356 microseconds.
Feb 23 07:10:47 cygnus-mongo.novalocal dhclient[1068]: DHCPREQUEST on eth0 to 192.168.111.71 port 67 (xid=0x6acae4e0)
Feb 23 07:10:48 cygnus-mongo.novalocal dhclient[1068]: DHCPACK from 192.168.111.71 (xid=0x6acae4e0)
Feb 23 07:10:50 cygnus-mongo.novalocal dhclient[1068]: bound to 192.168.111.128 -- renewal in 44 seconds.
Feb 23 07:10:57 cygnus-mongo.novalocal sudo[1255]: centos : TTY=pts/0 ; PWD=/home/centos ; USER=root ; COMMAND=/bin/journalctl -xn
Here is the service file that I did not change:
[centos#cygnus-mongo ~]$ cat /etc/rc.d/init.d/cygnus
#!/bin/bash
# Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U
#
# This file is part of fiware-cygnus (FI-WARE project).
#
# fiware-cygnus is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
# later version.
# fiware-cygnus 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 Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along with fiware-cygnus. If not, see
# http://www.gnu.org/licenses/.
#
# For those usages not covered by the GNU Affero General Public License please contact with iot_support at tid dot es
#
# cygnus Start/Stop cygnus
#
# chkconfig: 2345 99 60
# description: cygnus
# Load some fancy functions for init.d
. /etc/rc.d/init.d/functions
PARAM=$1
CYGNUS_INSTANCE=${2}
COMPONENT_NAME=cygnus
PREFIX=/usr
CYGNUS_DIR=${PREFIX}/cygnus
FLUME_EXECUTABLE=${CYGNUS_DIR}/bin/cygnus-flume-ng
CYGNUS_USER=cygnus
cygnus_start()
{
local result=0
local cygnus_instance=${1}
if [[ ! -x ${FLUME_EXECUTABLE} ]]; then
printf "%s\n" "Fail - ${FLUME_EXECUTABLE} not exists or is not executable."
exit 1
fi
if [[ $(ls -l ${CYGNUS_DIR}/conf/cygnus_instance_${cygnus_instance}*.conf 2> /dev/null | wc -l) -eq 0 ]]; then
if [[ ${cygnus_instance} == "" ]]; then
printf "%s\n" "There aren't any instance of Cygnus configured. Refer to file /usr/cygnus/conf/README.md for further information."
else
printf "%s\n" "There aren't any instance of Cygnus configured with the name ${cygnus_instance}. Refer to file /usr/cygnus/conf/README.md for further information."
fi
return 1
fi
for instance in $(ls ${CYGNUS_DIR}/conf/cygnus_instance_${cygnus_instance}*.conf)
do
local NAME
NAME=${instance%.conf}
NAME=${NAME#*cygnus_instance_}
. ${instance}
CYGNUS_PID_FILE="/var/run/cygnus/cygnus_${NAME}.pid"
printf "%s" "Starting Cygnus ${NAME}... "
status -p ${CYGNUS_PID_FILE} ${FLUME_EXECUTABLE} &> /dev/null
if [[ ${?} -eq 0 ]]; then
printf "%s\n" " Already running, skipping $(success)"
continue
fi
CYGNUS_COMMAND="${FLUME_EXECUTABLE} agent -p ${ADMIN_PORT} --conf ${CONFIG_FOLDER} -f ${CONFIG_FILE} -n ${AGENT_NAME} -Dflume.log.file=${LOGFILE_NAME} &>> /var/log/cygnus/${LOGFILE_NAME} & echo \$! > ${CYGNUS_PID_FILE}"
su ${CYGNUS_USER} -c "${CYGNUS_COMMAND}"
sleep 2 # wait some time to know if flume is still alive
PID=$(cat ${CYGNUS_PID_FILE})
FLUME_PID=$(ps -ef | grep -v "grep" | grep "${PID:-not_found}")
if [[ -z ${FLUME_PID} ]]; then
printf "%s\n" "$(failure)"
result=$((${result}+1))
rm ${CYGNUS_PID_FILE}
else
chown ${CYGNUS_USER}:${CYGNUS_USER} ${CYGNUS_PID_FILE}
printf "%s\n" "$(success)"
fi
done
return ${result}
}
cygnus_stop()
{
local result=0
local cygnus_instance=${1}
if [[ $(ls -l /var/run/cygnus/cygnus_${cygnus_instance}*.pid 2> /dev/null | wc -l) -eq 0 ]]; then
printf "%s\n" "There aren't any instance of Cygnus ${cygnus_instance} running $(success)"
return 0
fi
for run_instance in $(ls /var/run/cygnus/cygnus_${cygnus_instance}*.pid)
do
local NAME
NAME=${run_instance%.pid}
NAME=${NAME#*cygnus_}
printf "%-50s" "Stopping Cygnus ${NAME}..."
PID=$(cat ${run_instance})
kill -HUP ${PID} &> /dev/null
sleep 2
FLUME_PID=$(ps -ef | grep -v "grep" | grep "${PID:-not_found}")
if [[ -z ${FLUME_PID} ]]; then
rm -f ${run_instance}
printf "%s\n" "$(success)"
else
printf "%s\n" "$(failure)"
result=$((${result}+1))
rm -f ${run_instance}
fi
done
return ${result}
}
cygnus_status()
{
local result=0
local cygnus_instance=${1}
if [[ $(ls -l /var/run/cygnus/cygnus_${cygnus_instance}*.pid 2> /dev/null | wc -l) -eq 0 ]]; then
printf "%s\n" "There aren't any instance of Cygnus ${cygnus_instance} running"
exit 1
fi
for run_instance in $(ls /var/run/cygnus/cygnus_${cygnus_instance}*.pid)
do
local NAME
NAME=${run_instance%.pid}
NAME=${NAME#*cygnus_}
printf "%s\n" "Cygnus ${NAME} status..."
status -p ${run_instance} ${FLUME_EXECUTABLE}
result=$((${result}+${?}))
done
return ${result}
}
case ${PARAM} in
'start')
cygnus_start ${CYGNUS_INSTANCE}
;;
'stop')
cygnus_stop ${CYGNUS_INSTANCE}
;;
'restart')
cygnus_stop ${CYGNUS_INSTANCE}
cygnus_start ${CYGNUS_INSTANCE}
;;
'status')
cygnus_status ${CYGNUS_INSTANCE}
;;
esac
my configuration is the following:
file cygnus_instance_mongo.conf :
# Who to run cygnus as. Note that you may need to use root if you want
# to run cygnus in a privileged port (<1024)
CYGNUS_USER=cygnus
# Where is the config folder
CONFIG_FOLDER=/usr/cygnus/conf
# Which is the config file
CONFIG_FILE=/usr/cygnus/conf/agent_mongo.conf
# Name of the agent. The name of the agent is not trivial, since it is the base for the Flume parameters
# naming conventions, e.g. it appears in .sources.http-source.channels=...
AGENT_NAME=cygnusagent
# Name of the logfile located at /var/log/cygnus. It is important to put the extension '.log' in order to the log rotation works properly
LOGFILE_NAME=/var/log/cygnus/cygnus.log
# Administration port. Must be unique per instance
ADMIN_PORT=8081
# Polling interval (seconds) for the configuration reloading
POLLING_INTERVAL=30
file agent_mongo.conf
cygnusagent.sources = http-source
cygnusagent.sinks = mongo-sink
cygnusagent.channels = mongo-channel
#=============================================
# source configuration
# channel name where to write the notification events
cygnusagent.sources.http-source.channels = mongo-channel
# source class, must not be changed
cygnusagent.sources.http-source.type = org.apache.flume.source.http.HTTPSource
# listening port the Flume source will use for receiving incoming notifications
cygnusagent.sources.http-source.port = 5050
# Flume handler that will parse the notifications, must not be changed
cygnusagent.sources.http-source.handler = com.telefonica.iot.cygnus.handlers.OrionRestHandler
# URL target
cygnusagent.sources.http-source.handler.notification_target = /notify
# Default service (service semantic depends on the persistence sink)
cygnusagent.sources.http-source.handler.default_service = def_serv
# Default service path (service path semantic depends on the persistence sink)
cygnusagent.sources.http-source.handler.default_service_path = def_servpath
# Number of channel re-injection retries before a Flume event is definitely discarded (-1 means infinite retries)
cygnusagent.sources.http-source.handler.events_ttl = 10
# Source interceptors, do not change
cygnusagent.sources.http-source.interceptors = ts gi
# TimestampInterceptor, do not change
cygnusagent.sources.http-source.interceptors.ts.type = timestamp
# GroupinInterceptor, do not change
cygnusagent.sources.http-source.interceptors.gi.type = com.telefonica.iot.cygnus.interceptors.GroupingInterceptor$Builder
# Grouping rules for the GroupingInterceptor, put the right absolute path to the file if necessary
# See the doc/design/interceptors document for more details
cygnusagent.sources.http-source.interceptors.gi.grouping_rules_conf_file = /usr/cygnus/conf/grouping_rules.conf
# ============================================
# OrionMongoSink configuration
# sink class, must not be changed
cygnusagent.sinks.mongo-sink.type = com.telefonica.iot.cygnus.sinks.OrionMongoSink
# channel name from where to read notification events
cygnusagent.sinks.mongo-sink.channel = mongo-channel
# FQDN/IP:port where the MongoDB server runs (standalone case) or comma-separated list of FQDN/IP:port pairs where the MongoDB replica set members run
cygnusagent.sinks.mongo-sink.mongo_hosts = 127.0.0.1:27017
# a valid user in the MongoDB server (or empty if authentication is not enabled in MongoDB)
cygnusagent.sinks.mongo-sink.mongo_username =
# password for the user above (or empty if authentication is not enabled in MongoDB)
cygnusagent.sinks.mongo-sink.mongo_password =
# prefix for the MongoDB databases
cygnusagent.sinks.mongo-sink.db_prefix = kura_
# prefix pro the MongoDB collections
cygnusagent.sinks.mongo-sink.collection_prefix = kura_
# true is collection names are based on a hash, false for human redable collections
cygnusagent.sinks.mongo-sink.should_hash = false
#=============================================
# mongo-channel configuration
# channel type (must not be changed)
cygnusagent.channels.mongo-channel.type = memory
# capacity of the channel
cygnusagent.channels.mongo-channel.capacity = 1000
# amount of bytes that can be sent per transaction
cygnusagent.channels.mongo-channel.transactionCapacity = 100
Any idea of what have I missed?
UPDATE after frb answer
I changed the log file path and I got a new error:
[centos#cygnus-mongo ~]$ sudo journalctl -xn
-- Logs begin at Thu 2016-03-03 08:21:08 UTC, end at Thu 2016-03-03 08:22:07 UTC. --
Mar 03 08:21:49 cygnus-mongo.novalocal su[1211]: pam_unix(su:session): session opened for user cygnus by (uid=0)
Mar 03 08:21:49 cygnus-mongo.novalocal cygnus[1206]: Starting Cygnus mongo... bash: /var/run/cygnus/cygnus_mongo.pid: No such file or directory
Mar 03 08:21:49 cygnus-mongo.novalocal su[1211]: pam_unix(su:session): session closed for user cygnus
Mar 03 08:21:51 cygnus-mongo.novalocal cygnus[1206]: cat: /var/run/cygnus/cygnus_mongo.pid: No such file or directory
Mar 03 08:21:51 cygnus-mongo.novalocal cygnus[1206]: [FAILED]
Mar 03 08:21:51 cygnus-mongo.novalocal cygnus[1206]: rm: cannot remove ‘/var/run/cygnus/cygnus_mongo.pid’: No such file or directory
Mar 03 08:21:51 cygnus-mongo.novalocal systemd[1]: cygnus.service: control process exited, code=exited status=1
Mar 03 08:21:51 cygnus-mongo.novalocal systemd[1]: Failed to start SYSV: cygnus.
-- Subject: Unit cygnus.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit cygnus.service has failed.
--
-- The result is failed.
Mar 03 08:21:51 cygnus-mongo.novalocal systemd[1]: Unit cygnus.service entered failed state.
Mar 03 08:22:07 cygnus-mongo.novalocal sudo[1277]: centos : TTY=pts/0 ; PWD=/home/centos ; USER=root ; COMMAND=/bin/journalctl -xn

Everything in the configuration is OK except for this line in cygnus_instance_mongo.conf:
LOGFILE_NAME=/var/log/cygnus/cygnus.log
It must be:
LOGFILE_NAME=cygnus.log
I.e. the name of the log file within /var/log/cygnus.
The error was reported in this line of the service logs:
bash: /var/log/cygnus//var/log/cygnus/cygnus.log: No such file or directory

Related

RHEL 8 systemctl startup script fails

I have an application startup script that works correctly under RHEL 7, using both the "service" and "systemctl" commands. However when I use the same startup script and service config file on RHEL 8, the "service" command will stop and start the application, but the "systemctl" command will not start it.
The contents of the alm.service file are:
[Unit]
Description=Application Lifecycle Management (ALM)
Documentation=https://software.microfocus.com/en-us/solutions/software-development-lifecycle
After=opt-repository.mount
[Service]
Type=forking
PIDFile=/var/opt/HP/ALM/runtime/MFALM.pid
User=alm
ExecStart=/etc/init.d/alm start
ExecStop=/etc/init.d/alm stop
[Install]
WantedBy=multi-user.target
The portion of the /etc/init.d/alm script that starts the application is:
#!/bin/bash
#
# chkconfig: 35 20 80
# Description: QC Application LifeCycle Management
#
export LANG="en_US.utf8"
source /etc/profile
start () {
echo -n "Starting HP ALM: "
#Log as alm if account is not the good one
testfile=/opt/repository/base_install/.test_$RANDOM_`date|sed 's/ //g'`
testcmd="touch $testfile"
rmcmd="rm $testfile"
if [ `id -u` -eq 0 ]; then
testcmd="su alm -c \"touch $testfile\""
rmcmd="su alm -c \"rm $testfile\""
fi
echo
eval "$testcmd" 2>/dev/null
if [ ! $? -eq 0 ]; then
echo $'\n'"$0 ERROR: UNABLE to access REPOSITORY (touch $testfile) on read-write mode !"
echo $'\n'"!!! ABORTING ALM restart !!!"
echo $'\n'"But this could also be caused by this `uname -n` client needing reboot due to NFS hang."
else
eval "$rmcmd"
cd /var/opt/HP/ALM/wrapper
id
ls -l HPALM
# ./HPALM start
/var/opt/HP/ALM/wrapper/HPALM start
echo "HPALM returned Status: " $?
ls -l /var/opt/HP/ALM/runtime/MFALM.pid
fi
}
The HPALM script forks the daemon process and creates the /var/opt/HP/ALM/runtime/MFALM.pid file when the process is started.
When I do service alm start the application starts correctly.
However, when I do systemctl start alm I get the following error in journalctl -xe
Oct 03 21:18:29 12ee04f4556c44c alm[1311785]: Starting QC ALM:
Oct 03 21:18:29 12ee04f4556c44c alm[1311785]: user ID uid=(alm) gid=(team_alm_L4_users)
Oct 03 21:18:29 12ee04f4556c44c alm[1311785]: calling ./HPALM start
Oct 03 21:18:29 12ee04f4556c44c alm[1311829]: uid=(alm) gid=(team_alm_L4_users)
Oct 03 21:18:29 12ee04f4556c44c alm[1311830]: -rwxr-xr-x. 1 alm team_alm_L4_users 54983 Oct 3 21:06 HPALM
Oct 03 21:18:29 12ee04f4556c44c alm[1311831]: /etc/init.d/alm: line 36: /var/opt/HP/ALM/wrapper/HPALM: Permission denied
Oct 03 21:18:29 12ee04f4556c44c alm[1311785]: HPALM returned Status: 126
Oct 03 21:18:29 12ee04f4556c44c alm[1311832]: ls: cannot access '/var/opt/HP/ALM/runtime/MFALM.pid': No such file or directory
The RHEL 8 release version is Red Hat Enterprise Linux release 8.6 (Ootpa)
These same files and scripts work correctly on RHEL 7.
Does anyone know what has changed with RHEL 8 that would cause this to fail with systemctl but allow it to work with service?

tinyproxy: How to manually install the most recent version 1.11.0 on Ubuntu? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 11 months ago.
Improve this question
I would like to install the most recent tinyproxy version 1.11.0 on Ubuntu. How can I do that?
Unfortunetly does sudo apt update; sudo apt install tinyproxy -y; not work for me and only gives me the most recent stable version 1.10.0 from 2018.
So I tried to download and unzip the most recent version on GitHub
https://github.com/tinyproxy/tinyproxy/releases
But I couldn't get it to work properly installed yet.
What I tried so far:
sudo apt update;
... [loading the unzipped tinyproxy 1.11.0 folder via own GitHub repo]
cd OwnGitHubRepo/tinyproxy-1.11.0
sudo apt-get install build-essential -y
sudo apt install autoconf -y
autoconf
./configure
make
sudo make install
The installation seems to have been working somehow as tinyproxy -v returns: tinyproxy 1.11.0
But I now can not run following command which I would usually do:
sudo /etc/init.d/tinyproxy restart;
As there is no tinyproxy folder inside /etc/ listed yet. :/
(Also sudo lsof -i:8888 doesn't show any listing server yet)
Documentations:
http://tinyproxy.github.io/
Tried under AWS EC2 Ubuntu Server 20.04 LTS (HVM), SSD Volume Type
Make sure you update the system with the latest packages
ubuntu#ip-172-30-2-209:~$ sudo su -
root#ip-172-30-2-209:~#
root#ip-172-30-2-209:~# apt-get update
root#ip-172-30-2-209:~# apt-get dist-upgrade
You can reboot the server if a new kernel is available
root#ip-172-30-2-209:~# reboot
Install the build tools:
root#ip-172-30-2-209:~# apt-get install build-essential
root#ip-172-30-2-209:~# apt-get install autoconf
Download the source code and build the software
root#ip-172-30-2-209:~# wget https://github.com/tinyproxy/tinyproxy/releases/download/1.11.0/tinyproxy-1.11.0.tar.bz2
root#ip-172-30-2-209:~# tar -jxvf tinyproxy-1.11.0.tar.bz2
root#ip-172-30-2-209:~# cd tinyproxy-1.11.0/
root#ip-172-30-2-209:~/tinyproxy-1.11.0# ./configure
root#ip-172-30-2-209:~/tinyproxy-1.11.0# make
root#ip-172-30-2-209:~/tinyproxy-1.11.0# make install
Important directories/files to track:
/usr/bin/mkdir -p '/usr/local/bin'
/usr/bin/install -c tinyproxy '/usr/local/bin'
/usr/bin/mkdir -p '/usr/local/share/tinyproxy'
/usr/bin/install -c -m 644 debug.html default.html stats.html '/usr/local/share/tinyproxy'
/usr/bin/mkdir -p '/usr/local/etc/tinyproxy'
/usr/bin/install -c -m 644 tinyproxy.conf '/usr/local/etc/tinyproxy'
/usr/bin/mkdir -p '/usr/local/share/man/man5'
/usr/bin/install -c -m 644 tinyproxy.conf.5 '/usr/local/share/man/man5'
/usr/bin/mkdir -p '/usr/local/share/man/man8'
/usr/bin/install -c -m 644 tinyproxy.8 '/usr/local/share/man/man8'
/usr/bin/mkdir -p '/usr/local/share/doc/tinyproxy'
/usr/bin/install -c -m 644 AUTHORS NEWS README README.md '/usr/local/share/doc/tinyproxy'
Configure the software
Symlink the configuration folder
root#ip-172-30-2-209:~/tinyproxy-1.11.0# ln -s /usr/local/etc/tinyproxy /etc/
root#ip-172-30-2-209:~/tinyproxy-1.11.0# ls -la /etc/ | grep tinyproxy
lrwxrwxrwx 1 root root 24 Apr 3 09:53 tinyproxy -> /usr/local/etc/tinyproxy
Check the nobody user group
root#ip-172-30-2-209:~/tinyproxy-1.11.0# cat /etc/passwd | grep nobody
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
root#ip-172-30-2-209:~/tinyproxy-1.11.0# cat /etc/group | grep 65534
nogroup:x:65534:
Since nobody is assigned to the nogroup group, change the Group element in tinyproxy config from nobody group to nogroup
root#ip-172-30-2-209:~/tinyproxy-1.11.0# sed -i s/'Group nobody'/'Group nogroup'/g /etc/tinyproxy/tinyproxy.conf
Configure the rest of tinyproxy to your expectations (here is the minimal setup)
root#ip-172-30-2-209:~/tinyproxy-1.11.0# cat /etc/tinyproxy/tinyproxy.conf | grep -v "^#\|^$"
User nobody
Group nogroup
Port 8888
Timeout 600
DefaultErrorFile "/usr/local/share/tinyproxy/default.html"
StatFile "/usr/local/share/tinyproxy/stats.html"
LogLevel Info
MaxClients 100
Allow 127.0.0.1
Allow ::1
ViaProxyName "tinyproxy"
Test the connection
root#ip-172-30-2-209:~/tinyproxy-1.11.0# tinyproxy -d -c /etc/tinyproxy/tinyproxy.conf
NOTICE Apr 03 09:56:13.294 [8179]: Initializing tinyproxy ...
NOTICE Apr 03 09:56:13.294 [8179]: Reloading config file
INFO Apr 03 09:56:13.294 [8179]: Setting "Via" header to 'tinyproxy'
NOTICE Apr 03 09:56:13.294 [8179]: Reloading config file finished
INFO Apr 03 09:56:13.294 [8179]: listen_sock called with addr = '(NULL)'
INFO Apr 03 09:56:13.294 [8179]: trying to listen on host[0.0.0.0], family[2], socktype[1], proto[6]
INFO Apr 03 09:56:13.294 [8179]: listening on fd [3]
INFO Apr 03 09:56:13.294 [8179]: trying to listen on host[::], family[10], socktype[1], proto[6]
INFO Apr 03 09:56:13.294 [8179]: listening on fd [4]
INFO Apr 03 09:56:13.294 [8179]: Now running as group "nogroup".
INFO Apr 03 09:56:13.294 [8179]: Now running as user "nobody".
INFO Apr 03 09:56:13.294 [8179]: Setting the various signals.
INFO Apr 03 09:56:13.294 [8179]: Starting main loop. Accepting connections.
CTRL+C
Create a service to run tinyproxy
root#ip-172-30-2-209:~/tinyproxy-1.11.0# nano /lib/systemd/system/tinyproxy.service
[Unit]
Description=tinyproxy service
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=nobody
Group=nogroup
ExecStart=/usr/local/bin/tinyproxy -d -c /etc/tinyproxy/tinyproxy.conf
[Install]
WantedBy=multi-user.target
Start the service and check if everything is working fine
root#ip-172-30-2-209:~/tinyproxy-1.11.0# systemctl enable tinyproxy.service
Created symlink /etc/systemd/system/multi-user.target.wants/tinyproxy.service → /lib/systemd/system/tinyproxy.service.
root#ip-172-30-2-209:~/tinyproxy-1.11.0# systemctl status tinyproxy.service
● tinyproxy.service - tinyproxy service
Loaded: loaded (/lib/systemd/system/tinyproxy.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2022-04-03 10:00:20 UTC; 5s ago
Main PID: 8236 (tinyproxy)
Tasks: 1 (limit: 1145)
Memory: 1.0M
CGroup: /system.slice/tinyproxy.service
└─8236 /usr/local/bin/tinyproxy -d -c /etc/tinyproxy/tinyproxy.conf
Apr 03 10:00:20 ip-172-30-2-209 tinyproxy[8236]: INFO Apr 03 10:00:20.980 [8236]: Setting "Via" header to 'tinyproxy'
Apr 03 10:00:20 ip-172-30-2-209 tinyproxy[8236]: NOTICE Apr 03 10:00:20.980 [8236]: Reloading config file finished
Apr 03 10:00:20 ip-172-30-2-209 tinyproxy[8236]: INFO Apr 03 10:00:20.980 [8236]: listen_sock called with addr = '(NULL)'
Apr 03 10:00:20 ip-172-30-2-209 tinyproxy[8236]: INFO Apr 03 10:00:20.980 [8236]: trying to listen on host[0.0.0.0], family[2], socktype[1], proto[6]
Apr 03 10:00:20 ip-172-30-2-209 tinyproxy[8236]: INFO Apr 03 10:00:20.980 [8236]: listening on fd [3]
Apr 03 10:00:20 ip-172-30-2-209 tinyproxy[8236]: INFO Apr 03 10:00:20.980 [8236]: trying to listen on host[::], family[10], socktype[1], proto[6]
Apr 03 10:00:20 ip-172-30-2-209 tinyproxy[8236]: INFO Apr 03 10:00:20.980 [8236]: listening on fd [4]
Apr 03 10:00:20 ip-172-30-2-209 tinyproxy[8236]: INFO Apr 03 10:00:20.980 [8236]: Not running as root, so not changing UID/GID.
Apr 03 10:00:20 ip-172-30-2-209 tinyproxy[8236]: INFO Apr 03 10:00:20.980 [8236]: Setting the various signals.
Apr 03 10:00:20 ip-172-30-2-209 tinyproxy[8236]: INFO Apr 03 10:00:20.980 [8236]: Starting main loop. Accepting connections.
Install net-tools to check the listening ports
root#ip-172-30-2-209:~/tinyproxy-1.11.0# apt-get install net-tools
root#ip-172-30-2-209:~/tinyproxy-1.11.0# netstat -napt | grep LISTEN | grep tinyproxy
tcp 0 0 0.0.0.0:8888 0.0.0.0:* LISTEN 8236/tinyproxy
tcp6 0 0 :::8888 :::* LISTEN 8236/tinyproxy
root#ip-172-30-2-209:~/tinyproxy-1.11.0# lsof -i:8888
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
tinyproxy 8236 nobody 3u IPv4 34119 0t0 TCP *:8888 (LISTEN)
tinyproxy 8236 nobody 4u IPv6 34120 0t0 TCP *:8888 (LISTEN)
Extras
a) Logging and Pid file
Prepare pid and log directories
root#ip-172-30-2-209:~/tinyproxy-1.11.0# mkdir /var/run/tinyproxy/
root#ip-172-30-2-209:~/tinyproxy-1.11.0# mkdir /var/log/tinyproxy/
root#ip-172-30-2-209:~/tinyproxy-1.11.0# chown -R nobody:nogroup /var/run/tinyproxy/
root#ip-172-30-2-209:~/tinyproxy-1.11.0# chown -R nobody:nogroup /var/log/tinyproxy/
Add pid and log parameters into tinyproxy config
root#ip-172-30-2-209:~/tinyproxy-1.11.0#
root#ip-172-30-2-209:~/tinyproxy-1.11.0# cat /etc/tinyproxy/tinyproxy.conf | grep ^LogFile
LogFile "/var/log/tinyproxy/tinyproxy.log"
root#ip-172-30-2-209:~/tinyproxy-1.11.0# cat /etc/tinyproxy/tinyproxy.conf | grep ^PidFile
PidFile "/var/run/tinyproxy/tinyproxy.pid"
Restart service
root#ip-172-30-2-209:~/tinyproxy-1.11.0# systemctl restart tinyproxy.service
b) Process limits
root#ip-172-30-2-209:~# ps aux | grep tinyproxy
nobody 64427 9.8 0.5 789836 10232 ? Ssl 12:11 0:00 /usr/local/bin/tinyproxy -d -c /etc/tinyproxy/tinyproxy.conf
root 65436 0.0 0.0 7696 644 pts/0 S+ 12:11 0:00 grep --color=auto tinyproxy
root#ip-172-30-2-209:~# cat /proc/64427/limits | grep "Max processes\|Max open files"
Max processes 7151 7151 processes
Max open files 1024 524288 files
To bump up those, edit the /lib/systemd/system/tinyproxy.service file and add the following lines in the [Service] section
[Service]
...
LimitNOFILE=700000
LimitNPROC=700000
...
Then reload systemd and restart the service
root#ip-172-30-2-209:~# systemctl daemon-reload
root#ip-172-30-2-209:~# systemctl restart tinyproxy.service
Check the results
root#ip-172-30-2-209:~# ps axu | grep tinyproxy
nobody 68439 0.6 0.1 533092 3068 ? Ssl 12:13 0:00 /usr/local/bin/tinyproxy -d -c /etc/tinyproxy/tinyproxy.conf
root 68490 0.0 0.0 7696 656 pts/0 S+ 12:13 0:00 grep --color=auto tinyproxy
root#ip-172-30-2-209:~# cat /proc/68439/limits | grep "Max processes\|Max open files"
Max processes 700000 700000 processes
Max open files 700000 700000 files

Fail to start a process as a service? (code=exited, status=203/EXEC)

I need to start the cassandra process as a service. To do that placed the following script inside the /etc/init.d directory as per the doc
so here is my script which I placed in init directory.
#!/bin/bash
# chkconfig: 2345 99 01
# description: Cassandra
. /etc/rc.d/init.d/functions
CASSANDRA_HOME=/home/cassandra/binaries/cassandra
CASSANDRA_BIN=$CASSANDRA_HOME/bin/cassandra
CASSANDRA_NODETOOL=$CASSANDRA_HOME/bin/nodetool
CASSANDRA_LOG=$CASSANDRA_HOME/logs/cassandra.log
CASSANDRA_PID=$CASSANDRA_HOME/cassandra.pid
CASSANDRA_LOCK=$CASSANDRA_HOME/cassandra.lock
PROGRAM="cassandra"
if [ ! -f $CASSANDRA_BIN ]; then
echo "File not found: $CASSANDRA_BIN"
exit 1
fi
RETVAL=0
start() {
if [ -f $CASSANDRA_PID ] && checkpid `cat $CASSANDRA_PID`; then
echo "Cassandra is already running."
exit 0
fi
echo -n $"Starting $PROGRAM: "
$CASSANDRA_BIN -p $CASSANDRA_PID -R >> $CASSANDRA_LOG 2>&1
sleep 60
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
touch $CASSANDRA_LOCK
echo_success
else
echo_failure
fi
echo
return $RETVAL
}
stop() {
if [ ! -f $CASSANDRA_PID ]; then
echo "Cassandra is already stopped."
exit 0
fi
echo -n $"Stopping $PROGRAM: "
# $CASSANDRA_NODETOOL -h 127.0.0.1 decommission
if kill `cat $CASSANDRA_PID`; then
RETVAL=0
rm -f $CASSANDRA_LOCK
echo_success
else
RETVAL=1
echo_failure
fi
echo
[ $RETVAL = 0 ]
}
status_fn() {
if [ -f $CASSANDRA_PID ] && checkpid `cat $CASSANDRA_PID`; then
echo "Cassandra is running."
exit 0
else
echo "Cassandra is stopped."
exit 1
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status_fn
;;
restart)
stop
start
;;
*)
echo $"Usage: $PROGRAM {start|stop|restart|status}"
RETVAL=3
esac
exit $RETVAL
However when execute the service cassandra start it ended up with an error as follows.
[root#casstestnode1 init.d]# service cassandra start
Starting cassandra (via systemctl): Job for cassandra.service failed because the control process exited with error code. See "systemctl status cassandra.service" and "journalctl -xe" for details.
[FAILED]
[root#casstestnode1 init.d]#
and
[root#casstestnode1 init.d]# systemctl status cassandra.service
● cassandra.service - SYSV: Cassandra
Loaded: loaded (/etc/rc.d/init.d/cassandra)
Active: failed (Result: exit-code) since Sun 2019-11-10 22:23:07 IST; 41s ago
Docs: man:systemd-sysv-generator(8)
Process: 2624 ExecStart=/etc/rc.d/init.d/cassandra start (code=exited, status=203/EXEC)
Nov 10 22:23:07 casstestnode1 systemd[1]: Starting SYSV: Cassandra...
Nov 10 22:23:07 casstestnode1 systemd[1]: cassandra.service: control process exited, code=exited status=203
Nov 10 22:23:07 casstestnode1 systemd[1]: Failed to start SYSV: Cassandra.
Nov 10 22:23:07 casstestnode1 systemd[1]: Unit cassandra.service entered failed state.
Nov 10 22:23:07 casstestnode1 systemd[1]: cassandra.service failed.
[root#casstestnode1 init.d]#
I reboot the VM and retried again and still error is same. Any linux expert, Please help.
Additionally here is the output of the journalctl -xe
[root#casstestnode1 init.d]# journalctl -xe
-- Unit session-3153.scope has begun starting up.
Nov 11 23:55:01 casstestnode1 systemd[1]: Started Session 3154 of user cassandra.
-- Subject: Unit session-3154.scope has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit session-3154.scope has finished starting up.
--
-- The start-up result is done.
Nov 11 23:55:01 casstestnode1 systemd[1]: Starting Session 3154 of user cassandra.
-- Subject: Unit session-3154.scope has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit session-3154.scope has begun starting up.
Nov 11 23:55:01 casstestnode1 CROND[24584]: (cassandra) CMD (. /home/cassandra/test/cr.sh)
Nov 11 23:55:01 casstestnode1 CROND[24585]: (cassandra) CMD (date >> /home/cassandra/test/ll.txt)
Nov 11 23:55:01 casstestnode1 postfix/pickup[23967]: A5210F1C27: uid=995 from=<cassandra>
Nov 11 23:55:01 casstestnode1 postfix/cleanup[24090]: A5210F1C27: message-id=<20191111182501.A5210F1C27#casstestnode1.localdomain>
Nov 11 23:55:01 casstestnode1 postfix/qmgr[2035]: A5210F1C27: from=<cassandra#casstestnode1.localdomain>, size=837, nrcpt=1 (queue activ
Nov 11 23:55:01 casstestnode1 postfix/pickup[23967]: A8301F1C29: uid=995 from=<cassandra>
Nov 11 23:55:01 casstestnode1 postfix/cleanup[24315]: A8301F1C29: message-id=<20191111182501.A8301F1C29#casstestnode1.localdomain>
Nov 11 23:55:01 casstestnode1 postfix/qmgr[2035]: A8301F1C29: from=<cassandra#casstestnode1.localdomain>, size=845, nrcpt=1 (queue activ
Nov 11 23:55:01 casstestnode1 postfix/local[24021]: A5210F1C27: to=<cassandra#casstestnode1.localdomain>, orig_to=<cassandra>, relay=loc
Nov 11 23:55:01 casstestnode1 postfix/cleanup[24090]: A987AF1C2A: message-id=<20191111182501.A987AF1C2A#casstestnode1.localdomain>
Nov 11 23:55:01 casstestnode1 postfix/qmgr[2035]: A987AF1C2A: from=<>, size=2878, nrcpt=1 (queue active)
Nov 11 23:55:01 casstestnode1 postfix/bounce[24164]: A5210F1C27: sender non-delivery notification: A987AF1C2A
Nov 11 23:55:01 casstestnode1 postfix/qmgr[2035]: A5210F1C27: removed
Nov 11 23:55:01 casstestnode1 postfix/local[23698]: A8301F1C29: to=<cassandra#casstestnode1.localdomain>, orig_to=<cassandra>, relay=loc
Nov 11 23:55:01 casstestnode1 postfix/cleanup[24315]: AA5AFF1C27: message-id=<20191111182501.AA5AFF1C27#casstestnode1.localdomain>
Nov 11 23:55:01 casstestnode1 postfix/qmgr[2035]: AA5AFF1C27: from=<>, size=2886, nrcpt=1 (queue active)
Nov 11 23:55:01 casstestnode1 postfix/bounce[24164]: A8301F1C29: sender non-delivery notification: AA5AFF1C27
Nov 11 23:55:01 casstestnode1 postfix/qmgr[2035]: A8301F1C29: removed
Nov 11 23:55:01 casstestnode1 postfix/local[24021]: A987AF1C2A: to=<cassandra#casstestnode1.localdomain>, relay=local, delay=0.01, delay
Nov 11 23:55:01 casstestnode1 postfix/qmgr[2035]: A987AF1C2A: removed
Nov 11 23:55:01 casstestnode1 postfix/local[23698]: AA5AFF1C27: to=<cassandra#casstestnode1.localdomain>, relay=local, delay=0.01, delay
Nov 11 23:55:01 casstestnode1 postfix/qmgr[2035]: AA5AFF1C27: removed
lines 1923-1959/1959 (END)
[root#casstestnode1 init.d]#
[root#casstestnode1 init.d]#
when I manually run the script
[root#casstestnode1 init.d]#
[root#casstestnode1 init.d]# ./cassandra start
Starting cassandra: [ OK ]
[root#casstestnode1 init.d]# ./cassandra status
Cassandra is running.
[root#casstestnode1 init.d]#
[root#casstestnode1 init.d]#
[root#casstestnode1 init.d]# service cassandra status
Cassandra is running.
[root#casstestnode1 init.d]# ./cassandra stop
Stopping cassandra: [ OK ]
[root#casstestnode1 init.d]#
[root#casstestnode1 init.d]# ./cassandra status
Cassandra is stopped.
[root#casstestnode1 init.d]# service cassandra status
Cassandra is stopped.
[root#casstestnode1 init.d]#
203 EXIT_EXEC The actual process execution failed (specifically, the execve(2) system call). Most likely this is caused by a missing or non-accessible executable file
As per systemd.exec man page
So root cause is
exact path is different not /etc/rc.d/init.d/cassandra - you can figure out using find /etc -name cassandra
file is not executable less likely as you can do it manually.
Firstly, it is possible you are having an acute form of copypasteitis:
init script was obtained from one location ("the internet")
cassandra files are locateed in a different path than the init script assumes
your error claims:
Nov 10 22:23:07 casstestnode1 systemd[1]: cassandra.service: control process exited, code=exited status=203
this 203 usually means some executable was not found upon exec*() system call
(i.e. exec was called with a non existing executable path)
Secondly, you are on systemd based distribution, so there is no need to use system V (old, obsolete) type init script
Let's see how to get you both on-board and up-to-date:
find yourself somebody else's supposedly working systemd unit file for cassandra (e.g. this one )
open systemd documentation on a side: redhat official systemd doc
put the unit file to the right location, edit it
after you've edited it, run systemctl daemon-reload
now try systemd-way to launch cassandra: systemctl start cassandra
So, after you have found why it shoots the error, please use thee
now, for the error in the logs
I found a answer from this link. The cause was there was a blank line at the beginning of my cassandra script before #!/bin/bash . Once I removed and then I executed below two commands and issue was fixed.
chkconfig --add cassandra
systemctl daemon-reload

How to use systemctl to restart a service

I created a system service which can be start/stop/restart by running the command service. But when I try to do it by systemctl I always got below error. I don't know what wrong with my script file. Why it can be managed by service not systemctl?
# systemctl restart cooltoo_storage
Job for cooltoo_storage.service failed because the control process exited with error code. See "systemctl status cooltoo_storage.service" and "journalctl -xe" for details.
Below is the output of "systemctl status cooltoo_storage.service"
# systemctl status cooltoo_storage.service
● cooltoo_storage.service - LSB: cooltoo storage provider
Loaded: loaded (/etc/rc.d/init.d/cooltoo_storage)
Active: failed (Result: exit-code) since Tue 2016-05-03 17:17:12 CST; 1min 29s ago
Docs: man:systemd-sysv-generator(8)
Process: 32268 ExecStart=/etc/rc.d/init.d/cooltoo_storage start (code=exited, status=203/EXEC)
May 03 17:17:12 Cool-Too systemd[1]: Starting LSB: cooltoo storage provider...
May 03 17:17:12 Cool-Too systemd[1]: cooltoo_storage.service: control process exited, code=exited status=203
May 03 17:17:12 Cool-Too systemd[1]: Failed to start LSB: cooltoo storage provider.
May 03 17:17:12 Cool-Too systemd[1]: Unit cooltoo_storage.service entered failed state.
May 03 17:17:12 Cool-Too systemd[1]: cooltoo_storage.service failed.
Below is my script file /etc/init.d/cooltoo_storage,
### BEGIN INIT INFO
# Provides: cooltoo storage provider
# Required-Start: $local_fs $remote_fs $network $time $named
# Should-Start: $time sendmail
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: cooltoo storage provider
# Description: cooltoo storage provider
# chkconfig: 2345 90 90
### END INIT INFO
start() {
nginx -c /data/nginx/nginx.config
}
stop() {
nginx -c /data/nginx/nginx.config -s stop
}
restart() {
nginx -c /data/nginx/nginx.config -s reload
}
status() {
echo ''
}
action="$#"
if [[ "$MODE" == "auto" && -n "$init_script" ]] || [[ "$MODE" == "service" ]]; then
action="$1"
shift
fi
case "$action" in
start)
start ; exit $?;;
stop)
stop ; exit $?;;
restart)
restart ; exit $?;;
status)
status ; exit $?;;
*)
echo "Usage: $0 {start|stop|restart|force-reload|status|run}"; exit 1;
esac

Can't find documents with MediaWiki 1.21 with the Lucene-search extension

We're running MediaWiki 1.21 on Ubuntu 12.04.3 with the Lucene-search extension 2.1.3 (from its build.properties file).
I followed the instructions for a Single Host Setup (using ant to build the jar), and Setting Up Suggestions for the Search Box. Things seemed to be working just fine. However, new documents aren't being matched by the type-ahead search feature. Looking at the filesystem, I see that there are various items in the application's indexes directory:
$ cd /usr/local/search/lucene-search-2/indexes
$ ls -l
total 24
drwxr-xr-x 10 root root 4096 Aug 20 2013 import
drwxr-xr-x 7 root root 4096 Apr 14 06:42 index
drwxr-xr-x 2 root root 4096 Apr 14 06:41 search
drwxr-xr-x 9 root root 4096 Aug 20 2013 snapshot
drwxr-xr-x 2 root root 4096 Aug 20 2013 status
drwxr-xr-x 8 root root 4096 Aug 20 2013 update
We have a daily cron job that runs the Lucene-search build command, which dumps the wiki database as xml, and then modifies files in the import and snapshot folders. I noticed that the job reads from the search folder, which contains symbolic links to the update folder:
$ ls -l search/
total 24
lrwxrwxrwx 1 root root 70 Feb 12 21:39 wikidb -> /usr/local/search/lucene-search-2/indexes/update/wikidb/20140212064727
lrwxrwxrwx 1 root root 73 Feb 12 21:39 wikidb.hl -> /usr/local/search/lucene-search-2/indexes/update/wikidb.hl/20140212064727
lrwxrwxrwx 1 root root 76 Apr 14 06:41 wikidb.links -> /usr/local/search/lucene-search-2/indexes/update/wikidb.links/20140414064150
lrwxrwxrwx 1 root root 77 Feb 12 21:39 wikidb.prefix -> /usr/local/search/lucene-search-2/indexes/update/wikidb.prefix/20140212064728
lrwxrwxrwx 1 root root 78 Feb 12 21:39 wikidb.related -> /usr/local/search/lucene-search-2/indexes/update/wikidb.related/20140212064713
lrwxrwxrwx 1 root root 76 Feb 12 21:39 wikidb.spell -> /usr/local/search/lucene-search-2/indexes/update/wikidb.spell/20140212064740
Only the wikidb.links entry is current. The others are a couple of months old, which makes me think I missed something in how our daily cron task is setup. Here's the job:
#!/bin/sh
log=/var/log/lucene-search-2-cron.log
(
echo "Building wiki lucene-search indexes ..."
cd /usr/local/search/lucene-search-2
./build
echo "Stopping the lsearchd service..."
service lsearchd stop
# ok, so stopping the service apparently doesn't mean that the processes are gone, whack them manually
# See tip on using the "[x]yz" character class option so you don't need the additional "grep -v xyz":
# http://stackoverflow.com/questions/3510673/find-and-kill-a-process-in-one-line-using-bash-and-regex
echo "Killing any lucene-search processes that didn't terminate..."
kill -9 $(ps -ef | grep '[l]search' | awk '{print $2}')
echo "Starting the lsearchd service..."
service lsearchd start
) > $log 2>&1
And here's the service script /etc/init.d/lsearchd:
#!/bin/sh -e
### BEGIN INIT INFO
# Provides: lsearchd
# Required-Start: $syslog
# Required-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 1
# Short-Description: Start the Lucene Search daemon
# Description: Provide a Lucene Search backend for MediaWiki. Copied by John Ericson from: http://ubuntuforums.org/showthread.php?t
=1476445
### END INIT INFO
# Set to install directory of lucense-search. For example: /usr/local/lucene-search-2.1.3
LUCENE_SEARCH_DIR="/usr/local/search/lucene-search-2"
# Set username for daemon to run as. Can also use syntax "username:groupname" to also specify group for daemon to run as. For example: me:me
RUN_AS_USER="lsearchd"
OPTIONS="-configfile $LUCENE_SEARCH_DIR/lsearch.conf"
test -x $LUCENE_SEARCH_DIR/lsearchd || exit 0
test -n "$RUN_AS_USER" && CHUID_ARG="--chuid $RUN_AS_USER" || CHUID_ARG=""
if [ -f "/etc/default/lsearchd" ] ; then
. /etc/default/lsearchd
fi
. /lib/lsb/init-functions
case "$1" in
start)
cd $LUCENE_SEARCH_DIR
log_begin_msg "Starting Lucene Search Daemon..."
start-stop-daemon --start --quiet --oknodo --chdir $LUCENE_SEARCH_DIR --background $CHUID_ARG --exec $LUCENE_SEARCH_DIR/lsearchd -- $OPT
IONS
log_end_msg $?
;;
stop)
log_begin_msg "Stopping Lucene Search Daemon..."
start-stop-daemon --stop --quiet --oknodo --retry 2 --chdir $LUCENE_SEARCH_DIR $CHUID_ARG --exec $LUCENE_SEARCH_DIR/lsearchd
log_end_msg $?
;;
restart)
$0 stop
sleep 1
$0 start
;;
reload|force-reload)
log_begin_msg "Reloading Lucene Search Daemon..."
start-stop-daemon --stop -signal 1 --chdir $LUCENE_SEARCH_DIR $CHUID_ARG --exec $LUCENE_SEARCH_DIR/lsearchd
log_end_msg $?
;;
status)
status_of_proc $LUCENE_SEARCH_DIR/lsearchd lsearchd && exit 0 || exit $?
;;
*)
log_success_msg "Usage: /etc/init.d/lsearchd {start|stop|restart|reload|force-reload|status}"
exit 1
esac
exit 0
Update #1:
I deleted the update directory and ran the build command manually from the console as root. As expected, it only generated the update/wikidb.links entry, none of the other folders exist. I reviewed my earlier setup notes, and don't see anything different, so how did those folders get created, and how do they get maintained?
Update #2:
I retraced my steps from the initial install, and couldn't see anything I missed. So on a chance, I stopped the service and ran lsearchd from the console, and it created the missing directories! So I terminated the process and tried things again: deleted the indexes folder and ran the cron script from the console as root. I confirmed that when run this way, lsearchd DID NOT create the missing directories. And of course, now I remember that I had run lsearchd from the console when initially setting things up, verifying that it was getting client queries for the wiki's Search input field. And these are the indexes it had been using for the lookups, which explains why new documents are not included.
Here is what the command looks like when run as a service:
$ ps -ef | grep [l]search
lsearchd 10192 1 0 14:02 ? 00:00:00 /bin/bash /usr/local/search/lucene-search-2/lsearchd -configfile /usr/local/search/lucene-search-2/lsearch.conf
lsearchd 10198 10192 0 14:02 ? 00:00:01 java -Djava.rmi.server.codebase=file:///usr/local/search/lucene-search-2/LuceneSearch.jar -Djava.rmi.server.hostname=AMWikiBugz -jar /usr/local/search/lucene-search-2/LuceneSearch.jar -configfile /usr/local/search/lucene-search-2/lsearch.conf
So the remaining question is:
Why does lsearchd NOT create the directories when run as a service?
This was a permissions issue. d'oh!
The cron job and service init scripts all execute as root, however the service process is instantiated as the lsearchd user. Once I changed ownership of /usr/local/search/lucene-search-2/indexes/ and all subdirectories to be owned by lsearchd:lsearchd, the lsearchd process was able to create the missing directories when run via the service under cron.
It would have helped if something along the way had logged an error message to syslog indicating that it couldn't write to the target folder.

Resources