From nobody Sun Sep 12 17:46:22 2021 X-Original-To: freebsd-erlang@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 557E217BAD40 for ; Sun, 12 Sep 2021 17:46:50 +0000 (UTC) (envelope-from dch@skunkwerks.at) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4H6xrB1FSzz4bjk for ; Sun, 12 Sep 2021 17:46:50 +0000 (UTC) (envelope-from dch@skunkwerks.at) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 020693200910; Sun, 12 Sep 2021 13:46:42 -0400 (EDT) Received: from imap44 ([10.202.2.94]) by compute4.internal (MEProxy); Sun, 12 Sep 2021 13:46:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=skunkwerks.at; h=mime-version:message-id:in-reply-to:references:date:from:to :subject:content-type:content-transfer-encoding; s=fm3; bh=3f5yc FxKiQSF0oVNaZBBKntqqHZTPC+ixFx0Gl6zKU4=; b=22O9lVoeVacIqWzNHk409 C7dV1cPwBlkyKA7nWo6uEtg6okD5c6D1q7Xf1wgcEMtyu17LOtT1VtRCqAOY5aHF 2wzKSmNIiL2oN169p5/x8gN7sohiXuzayAKrtAyv46KA3KTdJtn/9gqCqXLkXHif VS0dyC7mjGhq/BaEsq+p60+eBfd6vwutq90+GxXcUfrjF+MF6YsYigMuyXJtF2pK /nVJxEtXIwgHP6d5J/gbpByinmsiMJmTTcI2bk2TWbyleCLvqIt+yAWvX2eYtxqx o6hv+5CqT9dgJ7QDe1w9dfF76EfYovs7EqgFkAyLo6LOkYRlBpIN/j+ev4/J9dZK A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=3f5ycFxKiQSF0oVNaZBBKntqqHZTPC+ixFx0Gl6zK U4=; b=Bvf8h2HJ78xnO6vBiw/Av0EkFsCF5bXlx1HFcE8pHo+Clj4THA0mxNTtl OcueMqEqGVFbHeopTGkJ07+oHDxclBi3g4mT9jQNEAKLEa6pPq3KI+ogsfYlleAV f1hwEcJuUgGVOJ5nniNDn79jZ+3OHFmW4Nro0JewtwoTZnYHI6dCRf1MNwFipoF2 DPhq2hY2NNA5h0Ve3DivEwdkQ9VpCaZvEOtJuvzQhCbSYWTaM1EpbeFeBfCrrzKy CSrwDnBHgz3CP6hFt7A0PB+4DS0eS4+i6TD7q6Rz/gSXOsWJcvMh81n4+ENjRN5C 6YTARN0JM5zBmEa1d9CTj89jWLiYQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudeghedguddugecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtgfesthhqredtreerjeenucfhrhhomhepfdff rghvvgcuvehothhtlhgvhhhusggvrhdfuceouggthhesshhkuhhnkhifvghrkhhsrdgrth eqnecuggftrfgrthhtvghrnhepuddugfehtdeludffhfetleejvdegvdehleekiedvudek heeujeffhfelgeehudevnecuffhomhgrihhnpehhvgigrdhpmhdpshhrrdhhthdpvgigrg hmphhlvgdrnhgvthenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhl fhhrohhmpegutghhsehskhhunhhkfigvrhhkshdrrght X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 4D53BFA0AA5; Sun, 12 Sep 2021 13:46:42 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-1229-g7ca81dfce5-fm-20210908.005-g7ca81dfc List-Id: Support of Erlang-related ports List-Archive: https://lists.freebsd.org/archives/freebsd-erlang List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-erlang@freebsd.org Mime-Version: 1.0 Message-Id: <0c2ee194-88a6-45a4-930a-6873dcddf7e2@www.fastmail.com> In-Reply-To: <17bdad4f66b.ba53eff81041850.8710956708084381343@swiftsmsgateway.com> References: <17bdad4f66b.ba53eff81041850.8710956708084381343@swiftsmsgateway.com> Date: Sun, 12 Sep 2021 17:46:22 +0000 From: "Dave Cottlehuber" To: erlang , "Mike Jakubik" Subject: Re: Sample rc.d script for Elixir apps Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 4H6xrB1FSzz4bjk X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N On Sun, 12 Sep 2021, at 16:26, Mike Jakubik wrote: > Hello, > > I am looking for a simple rc.d script that i could use to start our=20 > Elixir apps on boot up, something that root will run as defined user=20 > and basically just run=C2=A0elixir --erl "-detached" -S mix phx.server= and=20 > track PID. Hi Mike Use releases, possibly with pid_file https://hex.pm/packages/pid_file This is probably more than you need, but you can likely trim it down or adapt as you need. https://git.sr.ht/~dch/elixir-freebsd-rc-skeleton/tree Basically this runs in our CI, builds an elixir release, creates a standard FreeBSD package directly, without needing a Makefile to maintain, and drops the resulting tarball into our package repos and it can simply be `pkg install...` or upgraded. Use ansible or whatever to leave /usr/local/etc/${APP} and any /etc/rc.conf.d/${APP} settings. I use this in numerous projects, where, for historical reasons), we don't build in a classic ports tree, but use pkg-create(8) to build a compatible package. We can then distribute this elixir app like any other project. If I re-did it today, it would probably be a mix task for simplicity. TLDR: - use git tags for sensible version numbers - rc.d is your future /usr/local/etc/rc.d/${APP} - build.sh cleans the dir and makes a .txz file (this might need to be amended to .pkg depending on how up to date you are) - mix.exs has a few additions/helpers you may want - app.sh ends up in /usr/local/bin/example.sh so you can run it like su -m www /usr/local/bin/example.sh or via the usual `service example start` as you prefer.=20 The release scripts used to be horrible for elixir, so I unpacked them and simplified all the unnecessary bits. This was 6 years ago, and the releases are better now than they were, but again this is It's BSD2 licenced, I'd appreciate a shout-out in your repo if you use it, even if its a private repo that's just fair play :-) I don't connect via a local iex for debugging, I just remsh in: $ iex --name iex@(hostname -s).example.net \ --remsh app@example.net \ --cookie ... \ --erl '-proto_dist inet6_tcp' Using inet6 because thats how we roll our jails. Thoughts and ideas for improvements welcomed. A+ Dave