<div dir="auto">This will work well for cases where unit shuts down gracefully. If unit does not shut down gracefully, then i think you will have the same startup problem. </div><div dir="auto"><br></div><div dir="auto">It’s a good point about the TCP socket. </div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 26 Apr 2022 at 11:50 am, <<a href="mailto:shanlei@asiainfo.com">shanlei@asiainfo.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)">I have reconsided the situation:<br>
compare to TCP sockets, if a TCP bind fails, we know other programs are <br>
using the socket ,the ops team then fix the mis-configured port number, <br>
change unit or other programs.<br>
the unix socket should behave similarly.<br>
the diffrence is when a tcp server is done, the socket is recycled by <br>
system, while the unix socket file is left in disk, which block "unit"'s <br>
next boot.<br>
may the idea patch is to unlink the unix socket file on shutdown, <br>
instead of startup?<br>
<br>
<br>
On 2022-04-25 14:38,Scott van Kalken wrote:<br>
> What if it were a command line option to delete on start? This way you<br>
> preserve the existing behaviour while introducing the desired<br>
> behaviour. It’s up to the user / admin to decide if they want to<br>
> “force delete” as an example.<br>
> <br>
> On Mon, 25 Apr 2022 at 4:33 pm, <<a href="mailto:shanlei@asiainfo.com" target="_blank">shanlei@asiainfo.com</a>> wrote:<br>
> <br>
>> I know the concern, that if we misconfigure the socket file, other<br>
>> file<br>
>> may be deleted accidentally.<br>
>> But if the program wont delete the file, bind will fail , that means<br>
>> we<br>
>> have to delete the file manually before every start. that not a good<br>
>> <br>
>> option to maintain a system.<br>
>> <br>
>> 在 2022-04-24 18:05,Александр Поволоцкий<br>
>> wrote:<br>
>>> Unlink socket that can be in use? I think it's not a good idea.<br>
>>> <br>
>>> On 24.04.2022 12:25, <a href="mailto:shanlei@asiainfo.com" target="_blank">shanlei@asiainfo.com</a> wrote:<br>
>>>> <br>
>>>> hello,guys,<br>
>>>> <br>
>>>> We found if we add a unix socket listener, the file was left in<br>
>> disk<br>
>>>> when unit got shutdown.<br>
>>>> If the unit starts again and load configuration from its state<br>
>> folder,<br>
>>>> it would fail with error msg "file exists",<br>
>>>> so We think the proper process is to "delete the legacy unix<br>
>> socket<br>
>>>> before start", and we present following patch:<br>
>>>> <br>
>>>> <br>
>>>> # HG changeset patch<br>
>>>> # User stdanley <<a href="mailto:shanlei@asiainfo.com" target="_blank">shanlei@asiainfo.com</a>><br>
>>>> # Date 1650792235 -28800<br>
>>>> #      Sun Apr 24 17:23:55 2022 +0800<br>
>>>> # Node ID 29738840c393f12c7d7aa8f3959ed1655b39cd4d<br>
>>>> # Parent  8e06a879600e83af11345d023c53c2ca445cf82c<br>
>>>> unlink legacy unix socket file before binding.<br>
>>>> <br>
>>>> diff -r 8e06a879600e -r 29738840c393 src/nxt_main_process.c<br>
>>>> --- a/src/nxt_main_process.c    Tue Apr 12 04:16:00 2022 +0100<br>
>>>> +++ b/src/nxt_main_process.c    Sun Apr 24 17:23:55 2022 +0800<br>
>>>> @@ -1142,6 +1142,15 @@<br>
>>>> }<br>
>>>> <br>
>>>> #endif<br>
>>>> +#if (NXT_HAVE_UNIX_DOMAIN)<br>
>>>> +<br>
>>>> +    if (sa->u.sockaddr.sa_family == AF_UNIX<br>
>>>> +        && sa->type == SOCK_STREAM<br>
>>>> +        && sa->u.sockaddr_un.sun_path[0] != '\0') {<br>
>>>> +<br>
>>>> +        (void) unlink(sa->u.sockaddr_un.sun_path);<br>
>>>> +}<br>
>>>> +#endif<br>
>>>> <br>
>>>> if (bind(s, &sa->u.sockaddr, sa->socklen) != 0) {<br>
>>>> err = nxt_errno;<br>
>>>> _______________________________________________<br>
>>>> unit mailing list -- <a href="mailto:unit@nginx.org" target="_blank">unit@nginx.org</a><br>
>>>> To unsubscribe send an email to <a href="mailto:unit-leave@nginx.org" target="_blank">unit-leave@nginx.org</a><br>
>>> _______________________________________________<br>
>>> unit mailing list -- <a href="mailto:unit@nginx.org" target="_blank">unit@nginx.org</a><br>
>>> To unsubscribe send an email to <a href="mailto:unit-leave@nginx.org" target="_blank">unit-leave@nginx.org</a><br>
>> _______________________________________________<br>
>> unit mailing list -- <a href="mailto:unit@nginx.org" target="_blank">unit@nginx.org</a><br>
>> To unsubscribe send an email to <a href="mailto:unit-leave@nginx.org" target="_blank">unit-leave@nginx.org</a><br>
> _______________________________________________<br>
> unit mailing list -- <a href="mailto:unit@nginx.org" target="_blank">unit@nginx.org</a><br>
> To unsubscribe send an email to <a href="mailto:unit-leave@nginx.org" target="_blank">unit-leave@nginx.org</a><br>
</blockquote></div></div>