From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: How to run --daemon in foreground? Date: Mon, 31 Oct 2016 07:47:28 +0200 Message-ID: <20161031054728.GA1452@protected.rcdrun.com> References: <20161029151559.GB30693@protected.rcdrun.com> <20161030153451214174078@bob.proulx.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1477892931 10098 195.159.176.226 (31 Oct 2016 05:48:51 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 31 Oct 2016 05:48:51 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Bob Proulx Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Oct 31 06:48:47 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c15SX-00012C-Gj for geh-help-gnu-emacs@m.gmane.org; Mon, 31 Oct 2016 06:48:37 +0100 Original-Received: from localhost ([::1]:33363 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c15Sa-0006zH-1l for geh-help-gnu-emacs@m.gmane.org; Mon, 31 Oct 2016 01:48:40 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39652) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c15S9-0006zC-3j for help-gnu-emacs@gnu.org; Mon, 31 Oct 2016 01:48:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c15S5-0006dE-7H for help-gnu-emacs@gnu.org; Mon, 31 Oct 2016 01:48:13 -0400 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:36782) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c15S5-0006cx-0Q for help-gnu-emacs@gnu.org; Mon, 31 Oct 2016 01:48:09 -0400 Original-Received: from protected.rcdrun.com (localhost [::1]) (AUTH: PLAIN securesender, TLS: TLSv1/SSLv3,256bits,AES256-SHA) by stw1.rcdrun.com with ESMTPSA; Sun, 30 Oct 2016 22:48:30 -0700 id 0000000000049DFC.000000005816DB2F.00007203 Original-Received: from localhost (localhost [127.0.0.1]) (uid 1001) by protected.rcdrun.com with local; Mon, 31 Oct 2016 08:47:28 +0300 id 0000000000025030.000000005816DAF0.000005F4 Content-Disposition: inline In-Reply-To: <20161030153451214174078@bob.proulx.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 217.170.207.13 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:111641 Archived-At: Dear Bob, Thank you for the suggestions. On Sun, Oct 30, 2016 at 05:50:37PM -0600, Bob Proulx wrote: > Jean Louis wrote: > > I wish to run emacs --daemon, that it stays in foreground. The daemon > > sometimes quits, and I wish to supervise it by using skarnet.org so > > excellent s6-rc service manager, to run emacs as user, and to restart > > it whenever necessary: http://skarnet.org/software/ > screen -S emacs -d -m -- emacs -f server-start > # -S emacs -- session name, give a meaningful name to session > # -d -m -- Start screen in "detached" mode. This creates a new > session but doesn't attach to it. This is useful > for system startup scripts. > # emacs -f server-start -- launch emacs and call function > > After starting emacs in this detached screen session then you can > attach to the running emacs server as you describe. Yes, I have tried with many options of screen, and now with your help, I have found the right solution. Screen is not allowed to detach, that way the supervision system s6-rc keeps it well in background. Emacs daemon is sometimes crashing, and now I have solution to turn it on in background, when the directory ~/Work is available. It means, when encrypted partition gets mounted. And with su - admin, I give to emacs the environment to run with, even I would like to give it just what is necessary, I don't know what it needs yet. System is now working, without thinking. #!/bin/execlineb if { s6-test -d /home/data1/protected/Work } su - admin -s /bin/bash -l -c "/usr/bin/screen -S emacs -D -m -- /usr/bin/emacs --user admin --chdir /home/data1/protected"