LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 09-02-2021, 01:22 AM   #1
gustav3000
LQ Newbie
 
Registered: Dec 2020
Posts: 29

Rep: Reputation: Disabled
Daemon lxd-client client is not running


I have a problem with my init service. After I started the service lxd-agent I tried to check its status. I can see in the output of /etc/rc.d/rc.lxd-agent status below message:

Code:
daemon:  lxd-agent is running (pid 3351) (client is not running)
Command lxc exec slackware-vm -- sudo -i redirects me into the proper bash shell. Can I just ignore the above message complaining about that client is not running and everything will work fine? daemon is the following program: http://libslack.org/daemon/.

Here's my /etc/rc.d/rc.lxd-agent script:

Code:
#!/bin/sh

PRGNAM="lxd-agent"
BIN="/run/lxd_config/drive/lxd-agent"
PID="/run"
CHDIR="/run/lxd_config/drive"

lxd_agent_start() {
  if /usr/bin/daemon --running --name "${PRGNAM}" --pidfiles "${PID}"; then
    echo "${PRGNAM} is already running."
  else
    echo -n "Starting ${PRGNAM}..."
    /usr/bin/daemon --respawn --name "${PRGNAM}" --pidfiles "${PID}" \
      --chdir "${CHDIR}" -- "${BIN}"
    echo "done."
  fi
}

lxd_agent_stop() {
  if /usr/bin/daemon --running --name "${PRGNAM}" --pidfiles "${PID}"; then
    echo -n "Stopping ${PRGNAM}..."
    /usr/bin/daemon --stop --name "${PRGNAM}" --pidfiles "${PID}"
    echo "done."
  else
    echo "${PRGNAM} is not running."
  fi
}

lxd_agent_restart() {
  if /usr/bin/daemon --running --name "${PRGNAM}" --pidfiles "${PID}"; then
    echo -n "Restarting ${PRGNAM}..."
    /usr/bin/daemon --restart --name "${PRGNAM}" --pidfiles "${PID}"
    echo "done."
  else
    echo "${PRGNAM} is not running."
    exit 1
  fi
}

lxd_agent_status() {
  /usr/bin/daemon --running --name "${PRGNAM}" --pidfiles "${PID}" --verbose
}

case $1 in
  "start")
    lxd_agent_start
    ;;
  "stop")
    lxd_agent_stop
    ;;
  "restart")
    lxd_agent_restart
    ;;
  "status")
    lxd_agent_status
    ;;
  *)
    echo "Usage: $0 {start|stop|restart|status}"
    exit 1
    ;;
esac

Last edited by gustav3000; 09-02-2021 at 01:51 AM.
 
Old 09-02-2021, 01:56 AM   #2
LuckyCyborg
Senior Member
 
Registered: Mar 2010
Posts: 3,500

Rep: Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308
I do not see how is used the daemon supervisor there, BUT you edited the original post, so all I've written bellow become obsolete - still I leave it here for reference for other people.

Also, in the other thread, I have given you the example init script from its source code, to have a reference for writing your own init script.

Long story short, the "daemon" supervisor is a daemon which knows to do all nice things the daemons do (going in background, logging, etc) , but designed to execute another program.

For example, the /usr/bin/pipewire is a regular program which does has no daemon abilities, as is designed to be executed by systemd as "user service", after the user logins, until the user logouts.

However, on Slackware -current we will want to "daemonize" it on the user side, so we use this command:

Code:
/usr/bin/daemon -frB --pidfiles=~/.run --name=pipewire /usr/bin/pipewire
The meaning of parameters:

-f run on foreground - we do not need to go background because we execute this command via a XDG autostart desktop file
-r respawn the client program if quits or crashes
-B bind to user session via elogind (not useful and/or applicable for you) and quit on logout
--pidfiles where the daemon supervisor puts the PID files of its instance and of its executed client program
--name the unique name of this instance, used in naming the PID files.

The last parameter is of course the client program, which is executed.

Again, this is the example init script given by daemon author (and found on source code tarball), as how is supposed to use it on a init script:
Code:
#!/bin/sh

# daemon - http://libslack.org/daemon/
#
# Copyright (C) 1999-2004, 2010, 2020-2021 raf <raf@raf.org>
#
# This program 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.
#
# This program 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 this program; if not, see <https://www.gnu.org/licenses/>.
#

# 20210304 raf <raf@raf.org>

# This is an example /etc/init.d script that shows how to use daemon(1)
# in that context. Note that this would need to be modified quite a bit
# to meet the usual conventions of any specific system but if you aren't
# concerned about that it should be usable. At least it's a starting point.

# The daemon's name (to ensure uniqueness and for stop, restart and status)
name="EXAMPLE"
# The path of the client executable
command="/usr/bin/EXAMPLE"
# Any command line arguments for the client executable
command_args=""
# The path of the daemon executable
daemon="/usr/bin/daemon"

[ -x "$daemon" ] || exit 0
[ -x "$command" ] || exit 0

# Note: The following daemon option arguments could be in /etc/daemon.conf
# instead. That would probably be better because if the command itself were
# there as well then we could just use the name here to start the daemon.
# Here's some code to do it here in case you prefer that.

# Any command line arguments for the daemon executable (when starting)
daemon_start_args="" # e.g. --inherit --env="ENV=VAR" --unsafe
# The pidfile directory (need to force this so status works for normal users)
pidfiles="/var/run"
# The user[:group] to run as (if not to be run as root)
user=""
# The path to chroot to (otherwise /)
chroot=""
# The path to chdir to (otherwise /)
chdir=""
# The umask to adopt, if any
umask=""
# The syslog facility or filename for the client's stdout (otherwise discarded)
stdout="daemon.info"
# The syslog facility or filename for the client's stderr (otherwise discarded)
stderr="daemon.err"

case "$1" in
	start)
		# This if statement isn't strictly necessary but it's user friendly
		if "$daemon" --running --name "$name" --pidfiles "$pidfiles"
		then
			echo "$name is already running."
		else
			echo -n "Starting $name..."
			"$daemon" --respawn $daemon_start_args \
				--name "$name" --pidfiles "$pidfiles" \
				${user:+--user $user} ${chroot:+--chroot $chroot} \
				${chdir:+--chdir $chdir} ${umask:+--umask $umask} \
				${stdout:+--stdout $stdout} ${stderr:+--stderr $stderr} \
				-- \
				"$command" $command_args
			echo done.
		fi
		;;

	stop)
		# This if statement isn't strictly necessary but it's user friendly
		if "$daemon" --running --name "$name" --pidfiles "$pidfiles"
		then
			echo -n "Stopping $name..."
			"$daemon" --stop --name "$name" --pidfiles "$pidfiles"
			echo done.
		else
			echo "$name is not running."
		fi
		;;

	restart|reload)
		if "$daemon" --running --name "$name" --pidfiles "$pidfiles"
		then
			echo -n "Restarting $name..."
			"$daemon" --restart --name "$name" --pidfiles "$pidfiles"
			echo done.
		else
			echo "$name is not running."
			exit 1
		fi
		;;

	status)
		"$daemon" --running --name "$name" --pidfiles "$pidfiles" --verbose
		;;

	*)
		echo "usage: $0 <start|stop|restart|reload|status>" >&2
		exit 1
esac

exit 0

# vi:set ts=4 sw=4:

Last edited by LuckyCyborg; 09-02-2021 at 02:16 AM.
 
Old 09-02-2021, 02:22 AM   #3
LuckyCyborg
Senior Member
 
Registered: Mar 2010
Posts: 3,500

Rep: Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308
Quote:
Originally Posted by gustav3000 View Post
I have a problem with my init service. After I started the service lxd-agent I tried to check its status. I can see in the output of /etc/rc.d/rc.lxd-agent status below message:

Code:
daemon:  lxd-agent is running (pid 3351) (client is not running)
This means that the client program (lxd-agent from whatever path) does not running. The daemon supervisor tried to execute it a certain number of times (because --respawn) then abandoned.

I have no idea what your "lxd-agent" do and how is supposed to behave, so I suggest you to run in foreground the start command, to see what your lxd-agent says. Or to look on logs, after configuring their usage.

Last edited by LuckyCyborg; 09-02-2021 at 02:32 AM.
 
Old 09-02-2021, 05:11 AM   #4
ZhaoLin1457
Senior Member
 
Registered: Jan 2018
Posts: 1,022

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Regarding
Code:
PRGNAM="lxd-agent"
which is the full path of this program?
 
  


Reply



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
[SOLVED] LXD container running Ubuntu 18.04 not able to connect to update servers Superspeed500 Linux - Networking 2 03-24-2019 12:46 PM
ipsec/strongswan server on docker works on lxd container not taumeister Linux - Containers 3 04-21-2018 07:57 AM
Anyone running lxd in a VMWare VM? Tell me about it. sundialsvcs Linux - Containers 9 06-13-2017 07:35 PM
LXer: Ubuntu LXD: Not a Docker replacement, a Docker enhancement LXer Syndicated Linux News 0 11-05-2014 08:40 PM
Bash script to verify the daemon is working if not, start the daemon kishoreru Linux - Newbie 7 09-23-2009 04:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 06:34 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration