1

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
sabrina2020
  • 2,102
  • 3
  • 25
  • 54

1 Answers1

1

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
frb
  • 3,738
  • 2
  • 21
  • 51
  • Thanks for your response, I updated my configuration but I got a new error :s – sabrina2020 Mar 03 '16 at 09:39
  • 1
    Due to previous failed runs it seems the "state" of the service is, let's say, inconsistent. Try adding a fake `/var/run/cygnus/cygnus_mongo.pid` and let's see if Cygnus service is able to remove it (that's what it is trying to do, but with no success, since the file does not exist) and continue running. – frb Mar 04 '16 at 14:59
  • actually the directory "/var/run/cygnus" was not created, so I created it and then I changed its permissions to 777, so the cygnus user can manage it.Thanks! – sabrina2020 Mar 18 '16 at 13:30