Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Architectures & Platforms Gentoo on AMD64
  • Search

OpenRC - problem with status of service

Have an x86-64 problem? Post here.
Locked
Advanced search
10 posts • Page 1 of 1
Author
Message
kolanim
n00b
n00b
Posts: 6
Joined: Wed Nov 09, 2016 5:14 pm

OpenRC - problem with status of service

  • Quote

Post by kolanim » Wed Nov 09, 2016 5:36 pm

I need help about init script.
I start the script and it says that it is ok (* Starting cored server ...) and when i hit one more time start command it's written * WARNING: cored has already been started. BUT when check status it's written crashed ( * status: crashed). When I do stop, script stops service on correct way.
The issue is status of service. I didn't implement status because it is built-in. Please help me how to solve issue about status.

Below is script
------------------------------------------------------------------------------------------------

Code: Select all

#!/sbin/openrc-run
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

depend() {
#need localmount
use net
}

start() {
        ebegin "Starting cored server"
        start-stop-daemon --umask 0 -d /home/app/control --user test --background --start --exec \
        env GENICAM_GENTL32_PATH="/usr/local/Vimba_1_3/AVTGigETL/CTI/x86_32bit" GENICAM_GENTL64_PATH="/usr/local/Vimba_1_3/AVTGigETL/CTI/x86_64bit" \
        /home/app/control/vmsis_cored \
        #--make-pidfile --pidfile /var/run/vmsis_cored.pid
eend $?
}

stop() {
        ebegin "Stopping vmsis_cored server"
        start-stop-daemon --user vlatacom --stop --exec /home/app/control/vmsis_cored \
        #--pidfile /var/run/vmsis_cored.pid --retry 5
        eend $?
}
------------------------------------------------------------------------------------------------

Application /home/app/control/vmsis_cored is a daemon.
When I start application in console everything is ok.

[Moderator edit: added

Code: Select all

 tags to preserve output layout. -Hu][/color][/i]
Top
Atom2
Apprentice
Apprentice
Posts: 185
Joined: Mon Aug 01, 2011 9:16 am

Re: OpenRC - problem with status of service

  • Quote

Post by Atom2 » Wed Nov 09, 2016 10:20 pm

kolanim,
I don't really know what you are trying to do, but this command line

Code: Select all

start-stop-daemon --umask 0 -d /home/app/control --user test --background --start --exec \
env GENICAM_GENTL32_PATH="/usr/local/Vimba_1_3/AVTGigETL/CTI/x86_32bit" GENICAM_GENTL64_PATH="/usr/local/Vimba_1_3/AVTGigETL/CTI/x86_64bit" \
/home/app/control/vmsis_cored \
#--make-pidfile --pidfile /var/run/vmsis_cored.pid
looks plain wrong syntactically.

Without going into too much further details of the rest of your script, I assume the respective code line should read as follows (NOTE: I have also re-orderd the command line to make it more logical - this, however, is not strictly necessary):

Code: Select all

start-stop-daemon --start --background \
--env GENICAM_GENTL32_PATH="/usr/local/Vimba_1_3/AVTGigETL/CTI/x86_32bit" \
--env GENICAM_GENTL64_PATH="/usr/local/Vimba_1_3/AVTGigETL/CTI/x86_64bit" \
--umask 0 \
--chdir /home/app/control \
--user test \
--pidfile /var/run/vmsis_cored.pid --make-pidfile \ 
--exec /home/app/control/vmsis_cored
Regards Atom2
Top
Roman_Gruber
Advocate
Advocate
Posts: 3854
Joined: Tue Oct 03, 2006 8:43 am
Location: Austro Bavaria

  • Quote

Post by Roman_Gruber » Wed Nov 09, 2016 10:41 pm

Please use the code tags, (buttons) and quote (buttons). There is a reason why they are there

I'm not sure if it's good coding practise to refer to a home subdirectory for a service? Should it not belong to /usr /var or somewhere else to the reference (FHS standard)?
Top
pjp
Administrator
Administrator
User avatar
Posts: 20668
Joined: Tue Apr 16, 2002 10:35 pm

Re: OpenRC - problem with status of service

  • Quote

Post by pjp » Thu Nov 10, 2016 4:40 am

kolanim wrote:when check status it's written crashed ( * status: crashed). When I do stop, script stops service on correct way.
kolanim wrote:The issue is status of service. I didn't implement status because it is built-in. Please help me how to solve issue about status.
What do you do to check the status to get the message "status: crashed" message?
Quis separabit? Quo animo?
Top
kolanim
n00b
n00b
Posts: 6
Joined: Wed Nov 09, 2016 5:14 pm

Re: OpenRC - problem with status of service

  • Quote

Post by kolanim » Thu Nov 10, 2016 9:07 am

Atom2 wrote:kolanim,
I don't really know what you are trying to do, but this command line

Code: Select all

start-stop-daemon --umask 0 -d /home/app/control --user test --background --start --exec \
env GENICAM_GENTL32_PATH="/usr/local/Vimba_1_3/AVTGigETL/CTI/x86_32bit" GENICAM_GENTL64_PATH="/usr/local/Vimba_1_3/AVTGigETL/CTI/x86_64bit" \
/home/app/control/vmsis_cored \
#--make-pidfile --pidfile /var/run/vmsis_cored.pid
looks plain wrong syntactically.

Without going into too much further details of the rest of your script, I assume the respective code line should read as follows (NOTE: I have also re-orderd the command line to make it more logical - this, however, is not strictly necessary):

Code: Select all

start-stop-daemon --start --background \
--env GENICAM_GENTL32_PATH="/usr/local/Vimba_1_3/AVTGigETL/CTI/x86_32bit" \
--env GENICAM_GENTL64_PATH="/usr/local/Vimba_1_3/AVTGigETL/CTI/x86_64bit" \
--umask 0 \
--chdir /home/app/control \
--user test \
--pidfile /var/run/vmsis_cored.pid --make-pidfile \ 
--exec /home/app/control/vmsis_cored
Regards Atom2
I edited script with your re-ordered code and the it behaves the same like before. start,stop, restart does how it is expected.
My service works properly, just status of the service is always crashed.
My application must be run as non-root user.
Any idea? A programmer will implement that a daemon creates pid file but he can do it next week. That's my last hope.
Top
kolanim
n00b
n00b
Posts: 6
Joined: Wed Nov 09, 2016 5:14 pm

Re: OpenRC - problem with status of service

  • Quote

Post by kolanim » Thu Nov 10, 2016 9:13 am

pjp wrote:
kolanim wrote:when check status it's written crashed ( * status: crashed). When I do stop, script stops service on correct way.
kolanim wrote:The issue is status of service. I didn't implement status because it is built-in. Please help me how to solve issue about status.
What do you do to check the status to get the message "status: crashed" message?
/etc/init.d/vmsis_cored status. It's important to give me correct status (started) because I will watchdog that service.
Top
kolanim
n00b
n00b
Posts: 6
Joined: Wed Nov 09, 2016 5:14 pm

  • Quote

Post by kolanim » Thu Nov 10, 2016 9:24 am

Roman_Gruber wrote:Please use the code tags, (buttons) and quote (buttons). There is a reason why they are there

I'm not sure if it's good coding practise to refer to a home subdirectory for a service? Should it not belong to /usr /var or somewhere else to the reference (FHS standard)?
It doesn't matter where is the home directory it will behave same. I need to discover why when I start service the status is crashed but everything works fine.
Top
kolanim
n00b
n00b
Posts: 6
Joined: Wed Nov 09, 2016 5:14 pm

OpenRC - problem with status of service

  • Quote

Post by kolanim » Thu Nov 10, 2016 10:24 am

The problem is solved. I forced programmer to implement that daemon creates a pid file. And after that status is ok.
Before the pid of process was different then in pid file.
Top
Atom2
Apprentice
Apprentice
Posts: 185
Joined: Mon Aug 01, 2011 9:16 am

Re: OpenRC - problem with status of service

  • Quote

Post by Atom2 » Thu Nov 10, 2016 2:44 pm

kolanim wrote:Before the pid of process was different then in pid file.
Well that suggests, that the script itself forced the process into the background (by creating a new process and thus daemonizing the process). As a result of this the PID written into the PID file by start-stop-daemon was clearly different: In fact it was the PID of the process that later started the daemonized process (probably in a double inderection) and that process clearly terminated after the daemonization. The method with --make-pidfile and --background used in your init script only works when the process started actually runs in the foreground. The backgrounding is then done by start-stop-daemon instead.

Have a look at the man page of start-stop-daemon. Under --make-pidfile it states:
-m, --make-pidfile
Saves the pid of the daemon in the file specified by the -p, --pidfile option. Only useful when used with daemons
that run in the foreground and forced into the background with the --b, --background option.
Regards Atom2
Top
kolanim
n00b
n00b
Posts: 6
Joined: Wed Nov 09, 2016 5:14 pm

Re: OpenRC - problem with status of service

  • Quote

Post by kolanim » Thu Nov 10, 2016 4:08 pm

Atom2 wrote:
kolanim wrote:Before the pid of process was different then in pid file.
Well that suggests, that the script itself forced the process into the background (by creating a new process and thus daemonizing the process). As a result of this the PID written into the PID file by start-stop-daemon was clearly different: In fact it was the PID of the process that later started the daemonized process (probably in a double inderection) and that process clearly terminated after the daemonization. The method with --make-pidfile and --background used in your init script only works when the process started actually runs in the foreground. The backgrounding is then done by start-stop-daemon instead.

Have a look at the man page of start-stop-daemon. Under --make-pidfile it states:
-m, --make-pidfile
Saves the pid of the daemon in the file specified by the -p, --pidfile option. Only useful when used with daemons
that run in the foreground and forced into the background with the --b, --background option.
Regards Atom2
Just to clearly. My daemon is made to go in background but daemon did not make pid file by itself.
The solution is implementation that feature by programmer. Script is not changed, just the order that you posted.
But I agree with you in all what you posted.
Top
Locked

10 posts • Page 1 of 1

Return to “Gentoo on AMD64”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic