Sign in Join

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

Mailing lists / lazarus / 2013-03

Linux service

13 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

Antonio Fortuny

Hi Folks.

I've a problem when launching a service in a Linuxbox (OpenSuse 12.1, VM under esxi).
The service program has been first developped in Win32. It is installed without problem, then ran and stopped and finally uninstalled. All functions run well as I get the events into the log file Then port on Linux, compile OK. Just adapt the log file name I've made a script based on the smb one. The service is called ipserviced the program itself /usr/local/bin/ipservice chkconfig'ed --add, --list, --level all run well. S01Servicename and corresponding K01... have been created into corresponding rc?.d folders So far, so good. But wen launching:
# service ipserviced start
Starting IpService daemon (is displayed by service launcher) shell is hung, some process is lanched, see:
root 2420 12428 0 10:10 pts/3 00:00:00 /bin/sh /sbin/service ipserviced start
root 2422 2420 0 10:10 pts/3 00:00:00 /bin/sh /etc/init.d/ipserviced start
root 2430 2422 0 10:10 pts/3 00:00:01 startproc -p /var/run/ipservice/ipservice.pid -W /var/run/ipservice/ipservice.pid /usr/local/bin/ipservice -r -D -s /usr/local/bin/ipservice.conf root 2431 2430 0 10:10 pts/3 00:00:00 /usr/local/bin/ipservice -r -D -s /usr/local/bin/ipservice.conf
but nothing happens: no pid id in /var/run/ipservice.ipservice.pid no file created in
'/tmp/' + ExtractFileNameWithoutExt(ParamStr(0)) + '.log'; It looks like if no code has been called.
When I kill the command line (Ctrl-C), boum:
Exception at 0000000000000000
Access violation.
but all processes listed above are killed

Any suggestion apprediated.

Antonio.

Reply by email

Michael Van Canneyt
to Antonio Fortuny
Antonio Fortuny wrote 21 lines
Hi Folks. I've a problem when launching a service in a Linuxbox (OpenSuse 12.1, VM under esxi). The service program has been first developped in Win32. It is installed without problem, then ran and stopped and finally uninstalled. All functions run well as I get the events into the log file Then port on Linux, compile OK. Just adapt the log file name I've made a script based on the smb one. The service is called ipserviced the program itself /usr/local/bin/ipservice chkconfig'ed --add, --list, --level all run well. S01Servicename and corresponding K01... have been created into corresponding rc?.d folders So far, so good. But wen launching: # service ipserviced start Starting IpService daemon (is displayed by service launcher) shell is hung, some process is lanched, see: root 2420 12428 0 10:10 pts/3 00:00:00 /bin/sh /sbin/service ipserviced start root 2422 2420 0 10:10 pts/3 00:00:00 /bin/sh /etc/init.d/ipserviced start root 2430 2422 0 10:10 pts/3 00:00:01 startproc -p /var/run/ipservice/ipservice.pid -W /var/run/ipservice/ipservice.pid /usr/local/bin/ipservice -r -D -s /usr/local/bin/ipservice.conf

1. Change this to use strace:

startproc -p /var/run/ipservice/ipservice.pid -W /var/run/ipservice/ipservice.pid strace -f -o /tmp/start.log /usr/local/bin/ipservice -r -D -s /usr/local/bin/ipservice.conf

in /tmp/start.log you'll then see what the process is doing.

2. Try starting the process manually
strace -f -o /tmp/start-man.log /usr/local/bin/ipservice -r -D -s /usr/local/bin/ipservice.conf

and see if there is a difference.

Michael.

Reply by email

Antonio Fortuny
to Antonio Fortuny: Hi Folks. I've a problem when launching a service in a Linuxbox (OpenSuse 12.1, VM under…

1. Change this to use strace:

startproc -p /var/run/ipservice/ipservice.pid -W
/var/run/ipservice/ipservice.pid strace -f -o /tmp/start.log /usr/local/bin/ipservice -r -D -s /usr/local/bin/ipservice.conf

Same behaviour, got a /tmp/start-man.log and start.log (very similar) 3983 execve("/usr/local/bin/ipservice", ["/usr/local/bin/ipservice", "-r", "-D", "-s", "/usr/local/bin/ipservice.conf"], [/* 56 vars */]) = 0 3983 brk(0) = 0x7bc000 3983 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1a74c7d000
3

between them, nothing related to ipservice(d)

last lines:
3983 sendto(3, "<14>Mar 15 11:20:51 ipservice: ["..., 96, MSG_NOSIGNAL, NULL, 0) = 96
3983 sendto(3, "<14>Mar 15 11:20:51 ipservice: ["..., 141, MSG_NOSIGNAL, NULL, 0) = 141
3983 rt_sigprocmask(SIG_BLOCK, [], [], 8) = 0
3983 rt_sigsuspend([]) = ? ERESTARTNOHAND (To be restarted)

<<< killed by me (Ctrl-C)
3983 --- SIGINT (Interrupt) @ 0 (0) ---
3983 --- SIGSEGV (Segmentation fault) @ 0 (0) --- 3983 +++ killed by SIGSEGV +++
in /tmp/start.log you'll then see what the process is doing.

2. Try starting the process manually
strace -f -o /tmp/start-man.log /usr/local/bin/ipservice -r -D -s /usr/local/bin/ipservice.conf

and see if there is a difference.

no significative difference between them

Michael.

Reply by email

Michael Van Canneyt
to Antonio Fortuny
Antonio Fortuny wrote 22 lines
1. Change this to use strace: startproc -p /var/run/ipservice/ipservice.pid -W /var/run/ipservice/ipservice.pid strace -f -o /tmp/start.log /usr/local/bin/ipservice -r -D -s /usr/local/bin/ipservice.conf Same behaviour, got a /tmp/start-man.log and start.log (very similar) 3983 execve("/usr/local/bin/ipservice", ["/usr/local/bin/ipservice", "-r", "-D", "-s", "/usr/local/bin/ipservice.conf"], [/* 56 vars */]) = 0 3983 brk(0) = 0x7bc000 3983 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1a74c7d000 3 between them, nothing related to ipservice(d) last lines: 3983 sendto(3, "<14>Mar 15 11:20:51 ipservice: ["..., 96, MSG_NOSIGNAL, NULL, 0) = 96 3983 sendto(3, "<14>Mar 15 11:20:51 ipservice: ["..., 141, MSG_NOSIGNAL, NULL, 0) = 141

-> the process is started and writes to the system log. You should see what happens in /var/log/syslog.

Michael.

Reply by email

Antonio Fortuny
to Michael Van Canneyt
-> the process is started and writes to the system log. You should see what happens in /var/log/syslog.

/var/log/messages:
Mar 15 11:14:29 linux-5yg5 ipservice: [Info] Daemon Sita - Pocket service current status: Start Pending
Mar 15 11:14:29 linux-5yg5 ipservice: [Info] Failed to start daemon SitaPocketService : Semaphore init failed (possibly too many concurrent threads)

both messages are written on every launch. The progran does not use any explicit semaphore

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

Reply by email

Michael Van Canneyt
to Antonio Fortuny
Antonio Fortuny wrote 12 lines
> > -> the process is started and writes to the system log. You should see > what happens in /var/log/syslog. /var/log/messages: Mar 15 11:14:29 linux-5yg5 ipservice: [Info] Daemon Sita - Pocket service current status: Start Pending Mar 15 11:14:29 linux-5yg5 ipservice: [Info] Failed to start daemon SitaPocketService : Semaphore init failed (possibly too many concurrent threads) both messages are written on every launch. The progran does not use any explicit semaphore
did you add
{$ifdef unix}
uses cthreads;
{$endif}

To your program's uses clause ?

Michael.

Reply by email

Antonio Fortuny
to Michael Van Canneyt

Le 15/03/2013 12:42, Michael Van Canneyt a ?crit :

Show quoted text 23 lines
On Fri, 15 Mar 2013, Antonio Fortuny wrote: >> >> -> the process is started and writes to the system log. You should see >> what happens in /var/log/syslog. > /var/log/messages: > Mar 15 11:14:29 linux-5yg5 ipservice: [Info] Daemon Sita - Pocket > service current status: Start Pending > Mar 15 11:14:29 linux-5yg5 ipservice: [Info] Failed to start daemon > SitaPocketService : Semaphore init failed (possibly too many > concurrent threads) > > both messages are written on every launch. The progran does not use > any explicit semaphore did you add {$ifdef unix} uses cthreads; {$endif} To your program's uses clause ?

yes, all units refering to threads

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

Reply by email

Michael Van Canneyt
to Antonio Fortuny: Le 15/03/2013 12:42, Michael Van Canneyt a ?crit : yes, all units refering to threads
Antonio Fortuny wrote 27 lines
Le 15/03/2013 12:42, Michael Van Canneyt a ?crit : > > > On Fri, 15 Mar 2013, Antonio Fortuny wrote: > >>> >>> -> the process is started and writes to the system log. You should see >>> what happens in /var/log/syslog. >> /var/log/messages: >> Mar 15 11:14:29 linux-5yg5 ipservice: [Info] Daemon Sita - Pocket >> service current status: Start Pending >> Mar 15 11:14:29 linux-5yg5 ipservice: [Info] Failed to start daemon >> SitaPocketService : Semaphore init failed (possibly too many >> concurrent threads) >> >> both messages are written on every launch. The progran does not use >> any explicit semaphore > > did you add > {$ifdef unix} > uses cthreads; > {$endif} > > To your program's uses clause ? yes, all units refering to threads

Did you define UseCThreads ? It is not automatically defined.

Michael.

Reply by email

Antonio Fortuny
to Michael Van Canneyt

Le 15/03/2013 13:48, Michael Van Canneyt a ?crit :

>> To your program's uses clause ? > yes, all units refering to threads Did you define UseCThreads ? It is not automatically defined.

yep; Added "-dUseCThreads" to Other of project options same behaviour and same messages in /var/log/messages

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

Reply by email

Antonio Fortuny
to Michael Van Canneyt: 1. Change this to use strace: startproc -p /var/run/ipservice/ipservice.pid -W…

I finally succeded to manage the service. The basic developmment done in WIN32 has been preserved. I've now a unique source project compiling and running on WIN32 and LINUX.
So far, so good.
There is only one thing which worries me: when stopping the service (aka service ipserviced stop) the service is really stopped but the event OnStop is not fired.
In the daemon script this line is executed on stop: killproc -p ${PID_FILE} -t 10 ${IPSERVICE_BIN} -TERM and it works. Same if I use -HUP.
Maybe did I miss something

Antonio.

Reply by email

Antonio Fortuny
to Antonio Fortuny

Le 19/03/2013 16:52, Antonio Fortuny a ?crit :

Show quoted text 11 lines
I finally succeded to manage the service. The basic developmment done in WIN32 has been preserved. I've now a unique source project compiling and running on WIN32 and LINUX. So far, so good. There is only one thing which worries me: when stopping the service (aka service ipserviced stop) the service is really stopped but the event OnStop is not fired. In the daemon script this line is executed on stop: killproc -p ${PID_FILE} -t 10 ${IPSERVICE_BIN} -TERM and it works. Same if I use -HUP. Maybe did I miss something

The shutdown event does work.

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

Reply by email

Michael Van Canneyt
to Antonio Fortuny
Antonio Fortuny wrote 16 lines
Le 19/03/2013 16:52, Antonio Fortuny a ?crit : > I finally succeded to manage the service. The basic developmment done in > WIN32 has been preserved. I've now a unique source project compiling and > running on WIN32 and LINUX. > So far, so good. > There is only one thing which worries me: when stopping the service (aka > service ipserviced stop) the service is really stopped but the event > OnStop is not fired. > In the daemon script this line is executed on stop: > killproc -p ${PID_FILE} -t 10 ${IPSERVICE_BIN} -TERM > and it works. Same if I use -HUP. > Maybe did I miss something The shutdown event does work.

That is normal. There is no real STOP on linux.
I had planned to use USR1/USR2 for this, but didn't get to that.

Michael.

Reply by email