Fix shellcheck warnings
This commit is contained in:
parent
dc999f9006
commit
9881eebf55
17 changed files with 90 additions and 75 deletions
|
@ -1,4 +1,7 @@
|
|||
#!/bin/sh -e
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
# ============================================
|
||||
# celeryd - Starts the Celery worker daemon.
|
||||
# ============================================
|
||||
|
@ -29,7 +32,7 @@
|
|||
#
|
||||
VERSION=10.1
|
||||
echo "celery init v${VERSION}."
|
||||
if [ $(id -u) -ne 0 ]; then
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "Error: This program can only be used by the root user."
|
||||
echo " Unprivileged users must use the 'celery multi' utility, "
|
||||
echo " or 'celery worker --detach'."
|
||||
|
@ -51,15 +54,19 @@ DEFAULT_PID_FILE="/var/run/celery/%n.pid"
|
|||
DEFAULT_LOG_FILE="/var/log/celery/%n.log"
|
||||
DEFAULT_LOG_LEVEL="INFO"
|
||||
DEFAULT_NODES="celery"
|
||||
DEFAULT_CELERYD="-m celery worker --detach"
|
||||
# DEFAULT_CELERYD="-m celery worker --detach"
|
||||
|
||||
CELERY_DEFAULTS=${CELERY_DEFAULTS:-"/etc/default/${SCRIPT_NAME}"}
|
||||
# Make sure executable configuration script is owned by root
|
||||
_config_sanity() {
|
||||
local path="$1"
|
||||
local owner=$(ls -ld "$path" | awk '{print $3}')
|
||||
local iwgrp=$(ls -ld "$path" | cut -b 6)
|
||||
local iwoth=$(ls -ld "$path" | cut -b 9)
|
||||
local path
|
||||
local owner
|
||||
local iwgrp
|
||||
local iwoth
|
||||
path="$1"
|
||||
owner=$(ls -ld "$path" | awk '{print $3}')
|
||||
iwgrp=$(ls -ld "$path" | cut -b 6)
|
||||
iwoth=$(ls -ld "$path" | cut -b 9)
|
||||
if [ "$(id -u $owner)" != "0" ]; then
|
||||
echo "Error: Config script '$path' must be owned by root!"
|
||||
echo
|
||||
|
@ -97,6 +104,7 @@ _config_sanity() {
|
|||
if [ -f "$CELERY_DEFAULTS" ]; then
|
||||
_config_sanity "$CELERY_DEFAULTS"
|
||||
echo "Using config script: $CELERY_DEFAULTS"
|
||||
# shellcheck disable=SC1090
|
||||
. "$CELERY_DEFAULTS"
|
||||
fi
|
||||
# Sets --app argument for CELERY_BIN
|
||||
|
@ -184,8 +192,10 @@ _get_pids() {
|
|||
found_pids=0
|
||||
my_exitcode=0
|
||||
for pidfile in $(_get_pidfiles); do
|
||||
local pid=$(cat "$pidfile")
|
||||
local cleaned_pid=$(echo "$pid" | sed -e 's/[^0-9]//g')
|
||||
local pid
|
||||
local cleaned_pid
|
||||
pid=$(cat "$pidfile")
|
||||
cleaned_pid=$(echo "$pid" | sed -e 's/[^0-9]//g')
|
||||
if [ -z "$pid" ] || [ "$cleaned_pid" != "$pid" ]; then
|
||||
echo "bad pid file ($pidfile)"
|
||||
one_failed=true
|
||||
|
@ -207,7 +217,7 @@ start_workers() {
|
|||
if [ ! -z "$CELERYD_ULIMIT" ]; then
|
||||
ulimit $CELERYD_ULIMIT
|
||||
fi
|
||||
_chuid $* start $CELERYD_NODES $DAEMON_OPTS \
|
||||
_chuid "$@" start $CELERYD_NODES $DAEMON_OPTS \
|
||||
--pidfile="$CELERYD_PID_FILE" \
|
||||
--logfile="$CELERYD_LOG_FILE" \
|
||||
--loglevel="$CELERYD_LOG_LEVEL" \
|
||||
|
@ -259,9 +269,12 @@ check_status() {
|
|||
one_failed=true
|
||||
break
|
||||
fi
|
||||
local node=$(basename "$pidfile" .pid)
|
||||
local pid=$(cat "$pidfile")
|
||||
local cleaned_pid=$(echo "$pid" | sed -e 's/[^0-9]//g')
|
||||
local node
|
||||
local pid
|
||||
local cleaned_pid
|
||||
node=$(basename "$pidfile" .pid)
|
||||
pid=$(cat "$pidfile")
|
||||
cleaned_pid=$(echo "$pid" | sed -e 's/[^0-9]//g')
|
||||
if [ -z "$pid" ] || [ "$cleaned_pid" != "$pid" ]; then
|
||||
echo "bad pid file ($pidfile)"
|
||||
one_failed=true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue