Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2014-06

service launch

5 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

A. Fortuny

Hi Folks.

OpenSuse 12.2
Based on the /etc/init.d/skeleton I've made a new service script named "service.test" replacing all what is needed (binary name, conf file, etc.) When i launch it (using: # service service.test start) it fails to launch. The /var/log/messages displays:

Jun 2 11:50:02 aforsrv service.test[26037]: Starting Service test Usage: /home/data2/sources/compiled/service.bin [command] Jun 2 11:50:02 aforsrv service.test[26037]: Where command is one of the following: Jun 2 11:50:02 aforsrv service.test[26037]: -i --install To install the program as a service Jun 2 11:50:02 aforsrv service.test[26037]: -u --uninstall To uninstall the service Jun 2 11:50:02 aforsrv service.test[26037]: -r --run To run the service Jun 2 11:50:02 aforsrv service.test[26037]: An unhandled exception occurred at $000000000046E48A : Jun 2 11:50:02 aforsrv service.test[26037]: EInOutError : Jun 2 11:50:02 aforsrv service.test[26037]: $000000000046E48A Jun 2 11:50:02 aforsrv service.test[26037]: $0000000000497C43 line 233 of ../lib/simplelogger.pas Jun 2 11:50:02 aforsrv service.test[26037]: $0000000000473316 line 48 of DaemonMapper.pas Jun 2 11:50:02 aforsrv service.test[26037]: $0000000000471C27 Jun 2 11:50:02 aforsrv startproc: startproc: exit status of parent of /home/data2/sources/compiled/service.bin: 217 Jun 2 11:50:02 aforsrv service.test[26037]: ..failed Jun 2 11:50:02 aforsrv systemd[1]: service.test.service: control process exited, code=exited status=7 Jun 2 11:50:02 aforsrv systemd[1]: Unit service.test.service entered failed state.

The program itself is written in FPC using Lazarus and when launched on its own it runs perfectly well:
# ./service.bin -r ( the -r parameter tells the program to run as a service).
Log file is present and readable, SIGHUP and SIGTERM are trapped and recorded. Everythning runs as expected, the service script excepted.

Any ideas ?

Thanks in advance,
Antonio.

---
Ce courrier ?lectronique ne contient aucun virus ou logiciel malveillant parce que la protection avast! Antivirus est active. http://www.avast.com

Reply by email

Michael Van Canneyt
to A. Fortuny
A. Fortuny wrote 45 lines
Hi Folks. OpenSuse 12.2 Based on the /etc/init.d/skeleton I've made a new service script named "service.test" replacing all what is needed (binary name, conf file, etc.) When i launch it (using: # service service.test start) it fails to launch. The /var/log/messages displays: Jun 2 11:50:02 aforsrv service.test[26037]: Starting Service test Usage: /home/data2/sources/compiled/service.bin [command] Jun 2 11:50:02 aforsrv service.test[26037]: Where command is one of the following: Jun 2 11:50:02 aforsrv service.test[26037]: -i --install To install the program as a service Jun 2 11:50:02 aforsrv service.test[26037]: -u --uninstall To uninstall the service Jun 2 11:50:02 aforsrv service.test[26037]: -r --run To run the service Jun 2 11:50:02 aforsrv service.test[26037]: An unhandled exception occurred at $000000000046E48A : Jun 2 11:50:02 aforsrv service.test[26037]: EInOutError : Jun 2 11:50:02 aforsrv service.test[26037]: $000000000046E48A Jun 2 11:50:02 aforsrv service.test[26037]: $0000000000497C43 line 233 of ../lib/simplelogger.pas Jun 2 11:50:02 aforsrv service.test[26037]: $0000000000473316 line 48 of DaemonMapper.pas Jun 2 11:50:02 aforsrv service.test[26037]: $0000000000471C27 Jun 2 11:50:02 aforsrv startproc: startproc: exit status of parent of /home/data2/sources/compiled/service.bin: 217 Jun 2 11:50:02 aforsrv service.test[26037]: ..failed Jun 2 11:50:02 aforsrv systemd[1]: service.test.service: control process exited, code=exited status=7 Jun 2 11:50:02 aforsrv systemd[1]: Unit service.test.service entered failed state. The program itself is written in FPC using Lazarus and when launched on its own it runs perfectly well: # ./service.bin -r ( the -r parameter tells the program to run as a service). Log file is present and readable, SIGHUP and SIGTERM are trapped and recorded. Everythning runs as expected, the service script excepted. Any ideas ?

Does your script add the -r option when running the service ?

Michael.

Reply by email

SPRL AFOR
to Michael Van Canneyt

Le 2/06/2014 16:42, Michael Van Canneyt a ?crit :

Show quoted text 53 lines
On Mon, 2 Jun 2014, A. Fortuny wrote: > Hi Folks. > > OpenSuse 12.2 > Based on the /etc/init.d/skeleton I've made a new service script > named "service.test" replacing all what is needed (binary name, conf > file, etc.) > When i launch it (using: # service service.test start) it fails to > launch. The /var/log/messages displays: > > Jun 2 11:50:02 aforsrv service.test[26037]: Starting Service test > Usage: /home/data2/sources/compiled/service.bin [command] > Jun 2 11:50:02 aforsrv service.test[26037]: Where command is one of > the following: > Jun 2 11:50:02 aforsrv service.test[26037]: -i --install To > install the program as a service > Jun 2 11:50:02 aforsrv service.test[26037]: -u --uninstall To > uninstall the service > Jun 2 11:50:02 aforsrv service.test[26037]: -r --run To run > the service > Jun 2 11:50:02 aforsrv service.test[26037]: An unhandled exception > occurred at $000000000046E48A : > Jun 2 11:50:02 aforsrv service.test[26037]: EInOutError : > Jun 2 11:50:02 aforsrv service.test[26037]: $000000000046E48A > Jun 2 11:50:02 aforsrv service.test[26037]: $0000000000497C43 line > 233 of ../lib/simplelogger.pas > Jun 2 11:50:02 aforsrv service.test[26037]: $0000000000473316 line > 48 of DaemonMapper.pas > Jun 2 11:50:02 aforsrv service.test[26037]: $0000000000471C27 > Jun 2 11:50:02 aforsrv startproc: startproc: exit status of parent > of /home/data2/sources/compiled/service.bin: 217 > Jun 2 11:50:02 aforsrv service.test[26037]: ..failed > Jun 2 11:50:02 aforsrv systemd[1]: service.test.service: control > process exited, code=exited status=7 > Jun 2 11:50:02 aforsrv systemd[1]: Unit service.test.service entered > failed state. > > > > > The program itself is written in FPC using Lazarus and when launched > on its own it runs perfectly well: > # ./service.bin -r ( the -r parameter tells the program to run as a > service). > Log file is present and readable, SIGHUP and SIGTERM are trapped and > recorded. Everythning runs as expected, the service script excepted. > > Any ideas ? Does your script add the -r option when running the service ?

Yes. It was what I first suspected when I saw the error. The script snippet for start is:
case "$1" in
start)
echo -n "Starting Service test "
## Start daemon with startproc(8). If this fails
## the return value is set appropriately by startproc. */sbin/startproc $FOO_BIN -r *
# Remember status and be verbose
rc_status -v

     ;;

Yes, don't smile, I kept the original variables :-D . The $FOO_BIN variable contains the good program name.
BTW, as you probably noticed it, " line 48 of DaemonMapper.pas" in the lines above calls a logger function in the program DaemonMapper*Destroy* procedure !

Antonio

Show quoted text 8 lines
Michael. -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

---
Ce courrier ?lectronique ne contient aucun virus ou logiciel malveillant parce que la protection avast! Antivirus est active. http://www.avast.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20140602/cf7a21f4/attachment.html>

Reply by email

A. Fortuny
to Michael Van Canneyt: Does your script add the -r option when running the service ? Michael.

Le 2/06/2014 16:42, Michael Van Canneyt a ?crit :

Show quoted text 53 lines
On Mon, 2 Jun 2014, A. Fortuny wrote: > Hi Folks. > > OpenSuse 12.2 > Based on the /etc/init.d/skeleton I've made a new service script > named "service.test" replacing all what is needed (binary name, conf > file, etc.) > When i launch it (using: # service service.test start) it fails to > launch. The /var/log/messages displays: > > Jun 2 11:50:02 aforsrv service.test[26037]: Starting Service test > Usage: /home/data2/sources/compiled/service.bin [command] > Jun 2 11:50:02 aforsrv service.test[26037]: Where command is one of > the following: > Jun 2 11:50:02 aforsrv service.test[26037]: -i --install To > install the program as a service > Jun 2 11:50:02 aforsrv service.test[26037]: -u --uninstall To > uninstall the service > Jun 2 11:50:02 aforsrv service.test[26037]: -r --run To run > the service > Jun 2 11:50:02 aforsrv service.test[26037]: An unhandled exception > occurred at $000000000046E48A : > Jun 2 11:50:02 aforsrv service.test[26037]: EInOutError : > Jun 2 11:50:02 aforsrv service.test[26037]: $000000000046E48A > Jun 2 11:50:02 aforsrv service.test[26037]: $0000000000497C43 line > 233 of ../lib/simplelogger.pas > Jun 2 11:50:02 aforsrv service.test[26037]: $0000000000473316 line > 48 of DaemonMapper.pas > Jun 2 11:50:02 aforsrv service.test[26037]: $0000000000471C27 > Jun 2 11:50:02 aforsrv startproc: startproc: exit status of parent > of /home/data2/sources/compiled/service.bin: 217 > Jun 2 11:50:02 aforsrv service.test[26037]: ..failed > Jun 2 11:50:02 aforsrv systemd[1]: service.test.service: control > process exited, code=exited status=7 > Jun 2 11:50:02 aforsrv systemd[1]: Unit service.test.service entered > failed state. > > > > > The program itself is written in FPC using Lazarus and when launched > on its own it runs perfectly well: > # ./service.bin -r ( the -r parameter tells the program to run as a > service). > Log file is present and readable, SIGHUP and SIGTERM are trapped and > recorded. Everythning runs as expected, the service script excepted. > > Any ideas ? Does your script add the -r option when running the service ?

Yesy it does.
AT the same time I have to apologize. After re-creating the service script from the original /etc/init.d/skeleton,
- changing the first line as a /bin/bash script
- adapt the comments in the INIT INFO about the service name
- change the service binary program
- change the conf file name
- add the -r to the launching of the service binary file everything runs OK;
I did forget to register the service (chkconfig) and to reload (systemctl --system daemon-reload)
Sorry for the annoyance and thanks anyway.

Antonio.

Show quoted text 9 lines
Michael. -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

---
Ce courrier ?lectronique ne contient aucun virus ou logiciel malveillant parce que la protection avast! Antivirus est active. http://www.avast.com

Reply by email

Koenraad Lelong
to A. Fortuny
A. Fortuny wrote 13 lines
Yesy it does. AT the same time I have to apologize. After re-creating the service script from the original /etc/init.d/skeleton, - changing the first line as a /bin/bash script - adapt the comments in the INIT INFO about the service name - change the service binary program - change the conf file name - add the -r to the launching of the service binary file everything runs OK; I did forget to register the service (chkconfig) and to reload (systemctl --system daemon-reload) Sorry for the annoyance and thanks anyway.

Beware ! Newer distro's use systemd. While I think the /etc/init.d scripts will still be supported for a while, eventually they will not run anymore.

I need to study systemd, because I also do have a daemon made with fpc and started with an init.d-script.

Koenraad

Reply by email