ablog

不器用で落着きのない技術者のメモ

RHEL 8.6 の起動・停止スクリプトをデバッグする

  • /etc/init.d/aws-kinesis-agent に set -x を追記
#! /usr/bin/env bash

set -x # ★追記

### BEGIN INIT INFO
# Provides:          aws-kinesis-agent
# Required-Start:    $network
# Required-Stop:     $network
# Short-Description: Daemon for Amazon Kinesis Agent.
# Description:       This script is responsible for running Amazon Kinesis Agent
#                    as a daemon.
### END INIT INFO
$ sudo service aws-kinesis-agent start
+ . /etc/init.d/functions
++ TEXTDOMAIN=initscripts
++ umask 022
++ PATH=/sbin:/usr/sbin:/bin:/usr/bin
++ export PATH
++ '[' 11845 -ne 1 -a -z '' ']'
++ '[' -d /run/systemd/system ']'
++ case "$0" in
++ _use_systemctl=1
++ '[' -z '' ']'
++ COLUMNS=80
++ '[' -z '' ']'
++ '[' -f /etc/sysconfig/init ']'
++ BOOTUP=color
++ RES_COL=60
++ MOVE_TO_COL='echo -en \033[60G'
++ SETCOLOR_SUCCESS='echo -en \033[1;32m'
++ SETCOLOR_FAILURE='echo -en \033[1;31m'
++ SETCOLOR_WARNING='echo -en \033[1;33m'
++ SETCOLOR_NORMAL='echo -en \033[0;39m'
++ LOGLEVEL=1
++ grep --quiet -e '\(/dev/ttyS\|not a tty\)'
++ LANG=C
++ tty
++ __sed_discard_ignored_files='/\(~\|\.bak\|\.old\|\.orig\|\.rpmnew\|\.rpmorig\|\.rpmsave\)$/d'
++ '[' 1 = 1 ']'
++ '[' xstart = xstart -o xstart = xstop -o xstart = xrestart -o xstart = xreload -o xstart = xtry-restart -o xstart = xforce-reload -o xstart = xcondrestart ']'
++ systemctl_redirect /etc/init.d/aws-kinesis-agent start
++ local s
++ local prog=aws-kinesis-agent
++ local command=start
++ local options=
++ case "$command" in
++ s='Starting aws-kinesis-agent (via systemctl): '
++ '[' -n '' ']'
++ systemctl show aws-kinesis-agent.service
++ systemctl show -p LoadState aws-kinesis-agent.service
++ grep -q not-found
++ action 'Starting aws-kinesis-agent (via systemctl): ' /bin/systemctl start aws-kinesis-agent.service
++ local STRING rc
++ STRING='Starting aws-kinesis-agent (via systemctl): '
++ echo -n 'Starting aws-kinesis-agent (via systemctl):  '
Starting aws-kinesis-agent (via systemctl):  ++ shift
++ /bin/systemctl start aws-kinesis-agent.service

++ success 'Starting aws-kinesis-agent (via systemctl): '
++ '[' color '!=' verbose -a -z '' ']'
++ echo_success
++ '[' color = color ']'
++ echo -en '\033[60G'
                                                           ++ echo -n '['
[++ '[' color = color ']'
++ echo -en '\033[1;32m'
++ echo -n '  OK  '
  OK  ++ '[' color = color ']'
++ echo -en '\033[0;39m'
++ echo -n ']'
]++ echo -ne '\r'
++ return 0
++ return 0
++ rc=0
++ echo

++ return 0
++ exit 0
$ sudo service aws-kinesis-agent stop
+ . /etc/init.d/functions
++ TEXTDOMAIN=initscripts
++ umask 022
++ PATH=/sbin:/usr/sbin:/bin:/usr/bin
++ export PATH
++ '[' 11933 -ne 1 -a -z '' ']'
++ '[' -d /run/systemd/system ']'
++ case "$0" in
++ _use_systemctl=1
++ '[' -z '' ']'
++ COLUMNS=80
++ '[' -z '' ']'
++ '[' -f /etc/sysconfig/init ']'
++ BOOTUP=color
++ RES_COL=60
++ MOVE_TO_COL='echo -en \033[60G'
++ SETCOLOR_SUCCESS='echo -en \033[1;32m'
++ SETCOLOR_FAILURE='echo -en \033[1;31m'
++ SETCOLOR_WARNING='echo -en \033[1;33m'
++ SETCOLOR_NORMAL='echo -en \033[0;39m'
++ LOGLEVEL=1
++ grep --quiet -e '\(/dev/ttyS\|not a tty\)'
++ LANG=C
++ tty
++ __sed_discard_ignored_files='/\(~\|\.bak\|\.old\|\.orig\|\.rpmnew\|\.rpmorig\|\.rpmsave\)$/d'
++ '[' 1 = 1 ']'
++ '[' xstop = xstart -o xstop = xstop -o xstop = xrestart -o xstop = xreload -o xstop = xtry-restart -o xstop = xforce-reload -o xstop = xcondrestart ']'
++ systemctl_redirect /etc/init.d/aws-kinesis-agent stop
++ local s
++ local prog=aws-kinesis-agent
++ local command=stop
++ local options=
++ case "$command" in
++ s='Stopping aws-kinesis-agent (via systemctl): '
++ '[' -n '' ']'
++ systemctl show aws-kinesis-agent.service
++ grep -q not-found
++ systemctl show -p LoadState aws-kinesis-agent.service
++ action 'Stopping aws-kinesis-agent (via systemctl): ' /bin/systemctl stop aws-kinesis-agent.service
++ local STRING rc
++ STRING='Stopping aws-kinesis-agent (via systemctl): '
++ echo -n 'Stopping aws-kinesis-agent (via systemctl):  '
Stopping aws-kinesis-agent (via systemctl):  ++ shift
++ /bin/systemctl stop aws-kinesis-agent.service
++ success 'Stopping aws-kinesis-agent (via systemctl): '
++ '[' color '!=' verbose -a -z '' ']'
++ echo_success
++ '[' color = color ']'
++ echo -en '\033[60G'
                                                           ++ echo -n '['
[++ '[' color = color ']'
++ echo -en '\033[1;32m'
++ echo -n '  OK  '
  OK  ++ '[' color = color ']'
++ echo -en '\033[0;39m'
++ echo -n ']'
]++ echo -ne '\r'
++ return 0
++ return 0
++ rc=0
++ echo

++ return 0
++ exit 0
  • ログを確認する
$ less /var/log/messages

...
 
Jul 13 06:05:25 ip-172-17-3-155 aws-kinesis-agent[11346]: + . /etc/init.d/functions
Jul 13 06:05:25 ip-172-17-3-155 aws-kinesis-agent[11346]: ++ TEXTDOMAIN=initscripts
Jul 13 06:05:25 ip-172-17-3-155 aws-kinesis-agent[11346]: ++ umask 022
Jul 13 06:05:25 ip-172-17-3-155 aws-kinesis-agent[11346]: ++ PATH=/sbin:/usr/sbin:/bin:/usr/bin
Jul 13 06:05:25 ip-172-17-3-155 aws-kinesis-agent[11346]: ++ export PATH
Jul 13 06:05:25 ip-172-17-3-155 aws-kinesis-agent[11346]: ++ '[' 1 -ne 1 -a -z '' ']'
Jul 13 06:05:25 ip-172-17-3-155 aws-kinesis-agent[11346]: ++ '[' -z '' ']'
Jul 13 06:05:25 ip-172-17-3-155 aws-kinesis-agent[11346]: ++ COLUMNS=80
Jul 13 06:05:25 ip-172-17-3-155 aws-kinesis-agent[11346]: ++ '[' -z '' ']'
Jul 13 06:05:25 ip-172-17-3-155 aws-kinesis-agent[11346]: ++ '[' -f /etc/sysconfig/init ']'
Jul 13 06:05:25 ip-172-17-3-155 aws-kinesis-agent[11346]: ++ BOOTUP=color
Jul 13 06:05:25 ip-172-17-3-155 aws-kinesis-agent[11346]: ++ RES_COL=60
Jul 13 06:05:25 ip-172-17-3-155 aws-kinesis-agent[11346]: ++ MOVE_TO_COL='echo -en \033[60G'
Jul 13 06:05:25 ip-172-17-3-155 aws-kinesis-agent[11346]: ++ SETCOLOR_SUCCESS='echo -en \033[1;32m'
Jul 13 06:05:25 ip-172-17-3-155 aws-kinesis-agent[11346]: ++ SETCOLOR_FAILURE='echo -en \033[1;31m'
Jul 13 06:05:25 ip-172-17-3-155 aws-kinesis-agent[11346]: ++ SETCOLOR_WARNING='echo -en \033[1;33m'
Jul 13 06:05:25 ip-172-17-3-155 aws-kinesis-agent[11346]: ++ SETCOLOR_NORMAL='echo -en \033[0;39m'