Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
OpenRC - problem with status of service
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo on AMD64
View previous topic :: View next topic  
Author Message
kolanim
n00b
n00b


Joined: 09 Nov 2016
Posts: 6

PostPosted: Wed Nov 09, 2016 5:36 pm    Post subject: OpenRC - problem with status of service Reply with quote

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:

#!/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] tags to preserve output layout. -Hu]
Back to top
View user's profile Send private message
Atom2
Apprentice
Apprentice


Joined: 01 Aug 2011
Posts: 178

PostPosted: Wed Nov 09, 2016 10:20 pm    Post subject: Re: OpenRC - problem with status of service Reply with quote

kolanim,
I don't really know what you are trying to do, but this command line
Code:
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:
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
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3790
Location: Austro Bavaria

PostPosted: Wed Nov 09, 2016 10:41 pm    Post subject: Reply with quote

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)?
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 16703

PostPosted: Thu Nov 10, 2016 4:40 am    Post subject: Re: OpenRC - problem with status of service Reply with quote

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?
_________________
Ladies and gentlemen, allow me to present, Man Not Caring. -- Perry Cox
Back to top
View user's profile Send private message
kolanim
n00b
n00b


Joined: 09 Nov 2016
Posts: 6

PostPosted: Thu Nov 10, 2016 9:07 am    Post subject: Re: OpenRC - problem with status of service Reply with quote

Atom2 wrote:
kolanim,
I don't really know what you are trying to do, but this command line
Code:
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:
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.
Back to top
View user's profile Send private message
kolanim
n00b
n00b


Joined: 09 Nov 2016
Posts: 6

PostPosted: Thu Nov 10, 2016 9:13 am    Post subject: Re: OpenRC - problem with status of service Reply with quote

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.
Back to top
View user's profile Send private message
kolanim
n00b
n00b


Joined: 09 Nov 2016
Posts: 6

PostPosted: Thu Nov 10, 2016 9:24 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
kolanim
n00b
n00b


Joined: 09 Nov 2016
Posts: 6

PostPosted: Thu Nov 10, 2016 10:24 am    Post subject: OpenRC - problem with status of service Reply with quote

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.
Back to top
View user's profile Send private message
Atom2
Apprentice
Apprentice


Joined: 01 Aug 2011
Posts: 178

PostPosted: Thu Nov 10, 2016 2:44 pm    Post subject: Re: OpenRC - problem with status of service Reply with quote

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:
Quote:
-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
Back to top
View user's profile Send private message
kolanim
n00b
n00b


Joined: 09 Nov 2016
Posts: 6

PostPosted: Thu Nov 10, 2016 4:08 pm    Post subject: Re: OpenRC - problem with status of service Reply with quote

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:
Quote:
-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.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo on AMD64 All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum