On Fr, 29.12.17 17:19, eshark ([email protected]) wrote:

> Hi, All
>       I tried to test the socket activation by a simple foobar.socket and 
> foobar.service, which are as the following:
>       foobar.socket: 
>        [Socket]
>        ListenStream=/dev/socket/foobar
> 
> 
>        [Install]
>        WantedBy=sockets.target 
> 
> 
>       foobar.service: 
>        [Service]
>        Type=simple
>        ExecStart=/usr/bin/test-socket
>       Restart=no
> 
> 
>      I also wrote a simple program to connect to /dev/socket/foobar , in 
> order to activitate the foobar.service.
>     When I ran the program,  the foobar.service  was started by systemd , and 
> the foobar.socket changed from 'listening' state to 'running' state. 
>      All works OK as expected,  but  when I killed the  test-socket,  it was 
> started again by the systemd, even if I didn't run my program.
>     And from the system journal logs , I found  that
>     "
> Line 2035: 31,29604,571630004,-;systemd[1]: foobar.socket got notified about 
> service death (failed permanently: no)
> Line 2038: 31,29605,571630065,-;systemd[1]: foobar.socket changed running -> 
> listening
> Line 2050: 31,29609,571632385,-;systemd[1]: Incoming traffic on foobar.socket
> Line 2056: 28,29611,571633087,-;systemd[1]: Cannot add dependency job for 
> unit systemd-bus-proxyd.socket, ignoring: Unit systemd-bus-proxyd.socket 
> failed to load: No such file or directory.
> Line 2056: 28,29611,571633087,-;systemd[1]: Cannot add dependency job for 
> unit systemd-bus-proxyd.socket, ignoring: Unit systemd-bus-proxyd.socket 
> failed to load: No such file or directory.
> Line 2065: 31,29614,571633544,-;systemd[1]: foobar.socket changed listening 
> -> running   
> "
>  It seems that immediately after the death of foobar.service,    some unknown 
> incoming traffic  on foobar.socket   made the foobar.service started again by 
> the systemd .
>   Could anyone give me some suggestion that  who connected to the 
> foobar.socket  ?   Any idea about how to debug this problem  is very 
> appreciated.

If your service is activated due to incoming traffic and you do not
process the incoming traffic and exit, then you will be started
immediately again, as the socket still has traffic queued.

The idea is usually to process everything queued up on the listening
socket, and then exit until the next incoming traffic.

If you never accept any of the incoming connections you hence will
make systemd busy loop around your service.

Lennart

-- 
Lennart Poettering, Red Hat
_______________________________________________
systemd-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to