All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Rusty Howell <rustyhowell@gmail.com>
Cc: bitbake-devel@lists.openembedded.org
Subject: Re: [bitbake-devel] [PATCH] bitbake: bitbake-prserv: add nodaemon option
Date: Tue, 16 Apr 2024 23:54:01 +0200	[thread overview]
Message-ID: <202404162154017d2d756b@mail.local> (raw)
In-Reply-To: <20240327064332.3381069-1-rustyhowell@gmail.com>

Hello,

It doesn't apply on master anymore, can you rebase?

Thanks!

On 27/03/2024 00:43:32-0600, Rusty Howell wrote:
> Add a --nodaemon option to the prserver so it stays in the foreground
> and does not fork and exit.
> 
> There are several reasons why one would prefer to run the prserver in the
> foreground and not as a daemon.  Systemd documentation indicates that non-forking
> processes are preferred over forking/daemonized ones. Other use cases include
> running the prserver in a docker container and put in a k8s cluster.
> 
> Signed-off-by: Rusty Howell <rustyhowell@gmail.com>
> ---
>  bin/bitbake-prserv |  4 ++++
>  lib/prserv/serv.py | 16 ++++++++++++++++
>  2 files changed, 20 insertions(+)
> 
> diff --git a/bin/bitbake-prserv b/bin/bitbake-prserv
> index 5be42f3c..0d755fcb 100755
> --- a/bin/bitbake-prserv
> +++ b/bin/bitbake-prserv
> @@ -32,6 +32,8 @@ def main():
>                        dest="logfile", type="string", default="prserv.log")
>      parser.add_option("--loglevel", help="logging level, i.e. CRITICAL, ERROR, WARNING, INFO, DEBUG",
>                        action = "store", type="string", dest="loglevel", default = "INFO")
> +    parser.add_option("--nodaemon", help="Run prserver in foreground",
> +                      action="store_true", dest="nodaemon")
>      parser.add_option("--start", help="start daemon",
>                        action="store_true", dest="start")
>      parser.add_option("--stop", help="stop daemon",
> @@ -50,6 +52,8 @@ def main():
>          ret=prserv.serv.start_daemon(options.dbfile, options.host, options.port,os.path.abspath(options.logfile), options.read_only)
>      elif options.stop:
>          ret=prserv.serv.stop_daemon(options.host, options.port)
> +    elif options.nodaemon:
> +        ret=prserv.serv.start_nodaemon(options.dbfile, options.host, options.port, options.read_only)
>      else:
>          ret=parser.print_help()
>      return ret
> diff --git a/lib/prserv/serv.py b/lib/prserv/serv.py
> index 5fc8863f..111e6e9f 100644
> --- a/lib/prserv/serv.py
> +++ b/lib/prserv/serv.py
> @@ -207,6 +207,22 @@ def run_as_daemon(func, pidfile, logfile):
>      os.remove(pidfile)
>      os._exit(0)
>  
> +
> +def start_nodaemon(dbfile, host, port, read_only=False):
> +    ip = socket.gethostbyname(host)
> +    dbfile = os.path.abspath(dbfile)
> +    # Ensure logging makes it to the logfile
> +    streamhandler = logging.StreamHandler()
> +    streamhandler.setLevel(logging.DEBUG)
> +    formatter = bb.msg.BBLogFormatter("%(levelname)s: %(message)s")
> +    streamhandler.setFormatter(formatter)
> +    logger.addHandler(streamhandler)
> +
> +    server = PRServer(dbfile, read_only=read_only)
> +    server.start_tcp_server(ip, port)
> +    server.serve_forever()
> +
> +
>  def start_daemon(dbfile, host, port, logfile, read_only=False):
>      ip = socket.gethostbyname(host)
>      pidfile = PIDPREFIX % (ip, port)
> -- 
> 2.25.1
> 

> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#16016): https://lists.openembedded.org/g/bitbake-devel/message/16016
> Mute This Topic: https://lists.openembedded.org/mt/105172873/3617179
> Group Owner: bitbake-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [alexandre.belloni@bootlin.com]
> -=-=-=-=-=-=-=-=-=-=-=-
> 


-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


      reply	other threads:[~2024-04-16 21:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-27  6:43 [PATCH] bitbake: bitbake-prserv: add nodaemon option Rusty Howell
2024-04-16 21:54 ` Alexandre Belloni [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202404162154017d2d756b@mail.local \
    --to=alexandre.belloni@bootlin.com \
    --cc=bitbake-devel@lists.openembedded.org \
    --cc=rustyhowell@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.