From owner-freebsd-current@freebsd.org Mon Aug 12 07:46:35 2019 Return-Path: Delivered-To: freebsd-current@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 952CDA850E; Mon, 12 Aug 2019 07:46:35 +0000 (UTC) (envelope-from agapon@gmail.com) Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 466SbG4hL7z3x6w; Mon, 12 Aug 2019 07:46:34 +0000 (UTC) (envelope-from agapon@gmail.com) Received: by mail-pl1-f193.google.com with SMTP id c2so47540599plz.13; Mon, 12 Aug 2019 00:46:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=bfIabdTHs8nmQNWDc3vNesAa9dnnuRt6RxNCllJF4y4=; b=uO9yfDK65T6BwyKbPXNUtYwhPL0NmUIA8CAJSyGVTTJDdv6PUTw7A3KTObexrJxuZZ hcdAYRtPDGCxFG9dTOIh6mO7SdWHS7uiSiMhJjV8k5W5dmCLXOTQ+xAIcdzEynvbFfFN qXc5gxvelStGnWUoX8v+gfjUDfrboST/w4jJZNVxP1nCzL7JmnmiR6V7dPE9Vr/yTRHZ lNX1LYbsLunTRgcq93PLkHaR1uVB2DSFELcnDAnjluWD6xC+JCxWvffrHQzJMOOFhv8M WsnOsxRxpTT6BW4ga13QI1dKPS6S4SgfFjeUU+8C6ZpbllW3wjyBiqJ67YHI8gCzAYHx oK3Q== X-Gm-Message-State: APjAAAUQv4CHDVrfCs+0ZMB55soaXWZKdV/D0ouYKpoUjwfj7kYTp1Ya JvbuYIbIGKaF+nIwxgk1P28iegai X-Google-Smtp-Source: APXvYqwwQMjE/V4jUGII6Rc+qEjLcYCtQB7WWCSjqcZ/AL/A/fhYKS5oFtHXYCN9iS738l9J3lnM3g== X-Received: by 2002:a17:902:bb81:: with SMTP id m1mr32098809pls.125.1565595992458; Mon, 12 Aug 2019 00:46:32 -0700 (PDT) Received: from [192.168.1.36] (broadband-82-140-206-197.atc.tvcom.ru. [82.140.206.197]) by smtp.googlemail.com with ESMTPSA id dw7sm11628532pjb.21.2019.08.12.00.46.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Aug 2019 00:46:31 -0700 (PDT) Subject: Re: rc script: manual stop vs system shutdown To: Ian Lepore , Warner Losh , "Rodney W. Grimes" Cc: FreeBSD Current , freebsd-rc@freebsd.org References: <2e50fb67-8a19-412b-19d2-14f5f20b61f8@FreeBSD.org> <201908011553.x71FrTCd060252@gndrsh.dnsmgr.net> From: Andriy Gapon Openpgp: preference=signencrypt Message-ID: <91d1a853-c449-481a-b001-7c1f54e28fdd@FreeBSD.org> Date: Mon, 12 Aug 2019 10:46:29 +0300 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 466SbG4hL7z3x6w X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of agapon@gmail.com designates 209.85.214.193 as permitted sender) smtp.mailfrom=agapon@gmail.com X-Spamd-Result: default: False [-4.14 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; RCVD_TLS_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[FreeBSD.org]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; RWL_MAILSPIKE_GOOD(0.00)[193.214.85.209.rep.mailspike.net : 127.0.0.18]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_HAM_SHORT(-0.97)[-0.972,0]; RCVD_IN_DNSWL_NONE(0.00)[193.214.85.209.list.dnswl.org : 127.0.5.0]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; IP_SCORE(-1.16)[ipnet: 209.85.128.0/17(-3.38), asn: 15169(-2.39), country: US(-0.05)]; FORGED_SENDER(0.30)[avg@FreeBSD.org,agapon@gmail.com]; RECEIVED_SPAMHAUS_PBL(0.00)[197.206.140.82.khpj7ygk5idzvmvt5x4ziurxhy.zen.dq.spamhaus.net : 127.0.0.11]; MIME_TRACE(0.00)[0:+]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; FROM_NEQ_ENVFROM(0.00)[avg@FreeBSD.org,agapon@gmail.com] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Aug 2019 07:46:35 -0000 On 01/08/2019 22:51, Ian Lepore wrote: > On Thu, 2019-08-01 at 21:14 +0300, Andriy Gapon wrote: >> On 01/08/2019 19:12, Warner Losh wrote: >>> >>> >>> On Thu, Aug 1, 2019, 10:53 AM Rodney W. Grimes >>> > >>> wrote: >>> >>> > >>> > Is it possible in an rc script to distinguish between a manual stop >>> > (e.g., service foo stop) and a stop during a system shutdown (via >>> > rc.shutdown) ? >>> > Are there any marker variables for that? >>> > Or something in the global system state? >>> >>> Not that I can think of, but I like this idea, >>> I am sure that use cases exist. >>> >>> >>> What is the use case that needs to disambiguate the two cases... >> >> I have one use case in mind and it's a truly special case. >> I want rc.d/watchdogd to gracefully stop watchdogd and to disable the >> watchdog timer when the stop action is requested manually. And I want >> it to stop watchdogd and set the watchdog timer to a special shutdown >> timeout during the shutdown. If the special timeout is configured, of >> course. >> > > The shutdown timeout is already supported: you just set '-x ' > in watchdogd_flags in rc.conf; no changes to the rc.d script needed. > > I think probably you don't even need the first part of what you want. > The -x arg covers you in the reboot case; most people probably won't > use it. But if you are using it, and you want to truly kill the dog, > you would just do "watchdog -t 0" after "service watchdogd stop". If > you really felt the need to cover that with a single service command, > then how about using "service watchdogd cancel" where the cancel verb > does the -t 0 after killing the daemon? I guess that there is more than one way to achieve what I want or something similar to that. Rather than "expend words" on a theoretical discussion, I decided to do this: https://reviews.freebsd.org/D21221 However, I am still open to the discussion and suggestions. One thing that I would prefer, though, is to make the watchdogd service as smart as possible -- but not smarter :-) -- that is, I would prefer to do without adding any new command verbs to it. -- Andriy Gapon