{"id":2446,"date":"2022-08-30T15:24:56","date_gmt":"2022-08-30T15:24:56","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/01\/12\/problem-about-supervisor-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:24:56","modified_gmt":"2022-08-30T15:24:56","slug":"problem-about-supervisor-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/problem-about-supervisor-collection-of-common-programming-errors\/","title":{"rendered":"problem about supervisor-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/57b12f9b90134614956b29a13cf7c343?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSebastian Sastre<br \/>\nwebserver daemon smalltalk supervisor start-stop-daemon<br \/>\nHow should I script daemontools superviser?I&#8217;ve started to use D. J. Bernsteins&#8217; daemontools to keep some processes running and is working fine. But now I need to monitor a couple of additional conditions on those processes and I&#8217;ve failed to find good info on how to do that.My scenario is that I have some processes running for a web app (pharo smalltalk virtual machines) and they respond http, each one in their port (that&#8217;s for the for loadbalance). I would like to somehow ping those to verify<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/8a95d7cb84f4b9624f80ff976a6a2bb3?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nMilton Hultgren<br \/>\nerlang otp supervisor<br \/>\nI&#8217;m trying to build a supervisor tree where I have this structure:1 root supervisor -&gt; 3 &#8220;level&#8221; supervisors -&gt; each level supervisor has an initializer supervisor -&gt; X number of workers (right now only 1 for the examples sake)But for some reason starting the second level supervisor makes the whole tree terminate, if I only start 1 root -&gt; 1 level -&gt; 1 init -&gt; 1 worker (or more workers) it&#8217;s fine, but as soon as I try to add more supervisors the tree terminates.-module(otp_supervisor). -behavior<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/bf1ef895fb46e301e56569e1adc725bc?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nPeer Stritzinger<br \/>\nerlang otp supervisor<br \/>\nI&#8217;m trying to understand what&#8217;s happening here:I have a supervisor that is cyclically restarting one client without triggering the MaxR, MaxT mechanism. The client just crashes slowly enough never to trigger the rate limitation.There would have been another mechanism that uses supervisor:which_children\/1 and delete_child\/2, start_child\/2 to adapt the set of children to reality (its scanning for USB devices trying to have one supervisor child per device found).This would normally behave like a s<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/d78fa5f5fa6954a3c774f3de4e5fa951?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nuser1040689<br \/>\nerlang supervisor gen-server<br \/>\nI&#8217;m trying implement a simple supervisor and just have it restart child processes if they fail. But, I don&#8217;t even know how to spawn more than one process under a supervisor! I looked at simple supervisor code on this site and found something-module(echo_sup). -behaviour(supervisor). -export([start_link\/0]). -export([init\/1]).start_link() -&gt;{ok, Pid} = supervisor:start_link(echo_sup, []),unlink(Pid). init(_Args) -&gt;{ok, {{one_for_one, 5, 60},[{echo_server, {echo_server, start_link, []},perm<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/0b2b51e4cceb4a0c1609b81815001b69?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nxrl<br \/>\nerlang behavior supervisor gen-server<br \/>\nI&#8217;m using erlang as a bridge between services and I was wondering what advice people had for handling downed connections?I&#8217;m taking input from local files and piping them out to AMQP and it&#8217;s conceivable that the AMQP broker could go down. For that case I would want to keep retrying to connect to the AMQP server but I don&#8217;t want to peg the CPU with those connections attempts. My inclination is to put a sleep into the reboot of the AMQP code. Wouldn&#8217;t that &#8216;hack&#8217; essentially circumvent the purpo<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/2807e279ada3bb19bad41a54af66114d?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nNick<br \/>\nerlang supervisor<br \/>\nI recently ran into a bug where an entire Erlang application died, yielding a log message that looked like this:=INFO REPORT==== 11-Jun-2010::11:07:25 ===application: myappexited: shutdowntype: temporaryI have no idea what triggered this shutdown, but the real problem I have is that it didn&#8217;t restart itself. Instead, the now-empty Erlang VM just sat there doing nothing.Now, from the research I&#8217;ve done, it looks like there are other &#8220;start types&#8221; you can give an application: &#8216;transient&#8217; and &#8216;perm<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/bf1ef895fb46e301e56569e1adc725bc?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nPeer Stritzinger<br \/>\nerlang otp supervisor<br \/>\nI have a one_for_one supervisor that handles similar and totally independent children.When there is a problem with one child, repeatedly crashing and triggering: =SUPERVISOR REPORT==== 30-Mar-2011::13:10:42 ===Supervisor: {local,gateway_sup}Context: shutdownReason: reached_max_restart_intensityOffender: [{pid,&lt;0.76.0&gt;}, &#8230;shutting itself down and also terminating all the innocent children that would just continue to run fine otherwise.How can I build a supervision tree out of sta<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/bc37de3aad39715554ddcf66bdca46d0?s=32&amp;d=identicon&amp;r=PG&amp;f=1\" \/><br \/>\n8 revs, 2 users 98%Flinkman<br \/>\nerlang supervisor<br \/>\nI tried to explain supervision trees.My best try is:ok, You get a chocolate box from the factory, with warranty, &#8220;Every bit will taste good.&#8221; Then if you find that one bit taste funny. You can throw the whole box away. Because you get a new from the factory. That is like supervision trees in Erlang. If one thread misbehave. There is a risk that all threads have bad state. If that is the case, the supervisor throw all threads away and start over. Like the chocolate box, you are the supervisor<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/bf1ef895fb46e301e56569e1adc725bc?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nPeer Stritzinger<br \/>\nerlang supervisor gen-fsm<br \/>\nI have a MAIN process that spawn an implementation of a gen_fsm behavior, but this MAIN process is not an implementation of supervisor behavior, its just another module. Let say the implementation of gen_fsm is called GAME_ROOM. My case is like this:When ever there are 3 peoples ready, the MAIN process will spawn a new GAME_ROOM. I use gen_fsm:start_link function to initiate a new GAME_ROOM, so if the GAME_ROOM exit by error, my MAIN process could spawn a new one, to replace the downed process.<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/72c87606e44fb8f9f7c42c3cb4db245d?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nbatman<br \/>\nerlang otp supervisor gen-server<br \/>\nEDIT: Below.Why is my supervised gen_server shutting down so quickly?I&#8217;ll give these organizational names to make it more clear the chain of command that I want in my application: First I&#8217;m starting with the &#8220;assembly_line_worker&#8221; then later I&#8217;ll add the &#8220;marketing_specialist&#8221; to my supervision tree&#8230;ceo_supervisor.erl-module(ceo_supervisor). -behaviour(supervisor).-export([start_link\/1]). -export([init\/1]).start_link(State) -&gt;supervisor:start_link({local,?MODULE}, ?MODULE, [State]).init([Ar<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/5rOZp.jpg?s=32&amp;g=1\" \/><br \/>\nSvetlin Mladenov<br \/>\nerlang otp supervisor<br \/>\nI have a simple supervisor configuration:-module(my_supervisor). -behaviour(supervisor). -export([start_link\/0, init\/1]).init(_Args) -&gt;{ok, { {one_for_one, 5, 10},[{my_worker, {my_worker, start_link, []}, permanent, 5000, worker, [my_worker]}]} }.And even simple worker:-module(my_worker). -export([start_link\/0]). start_link() -&gt;%??? is this the first time the supervisor is starting me or have I crashed and been restarted???So is it even possible to determine whether this is the first time<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/bf1ef895fb46e301e56569e1adc725bc?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nPeer Stritzinger<br \/>\nerlang otp supervisor gen-server<br \/>\nWhen starting gen_server&#8217;s from a supervisor (which itself is started by a application) I have the problem that when the start_link of the gen_server doesn&#8217;t return {ok, &#8230;} but {error, Reason} the only error message I see is:=INFO REPORT==== 20-Jan-2011::13:14:43 ===application: fooexited: {shutdown,{foo_app,start,[normal,[]]}}type: temporaryThe Reason that for terminating is not shown\/logged.Is there a way to see\/log these error returns to the supervisor?The childspec I&#8217;m using is e.g.:{ok, {<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/48e0de87b5668bafdac073cf69aad7b0?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nsimpleBob<br \/>\nerlang behavior spawn supervisor<br \/>\nI have a structure like this&#8212;&#8212;&#8212;&#8212;- |Supervisor | &#8212;&#8212;&#8212;&#8212;-| &#8212;&#8212;&#8212;&#8212;- | Child1 | &#8212;&#8212;&#8212;&#8212;-| &#8212;&#8212;&#8212;&#8212;- | Child2 | &#8212;&#8212;&#8212;&#8212;-In this structure, child1 is supervised and it spawns child2. What I need is to be able to restart child1 when child2 crashes\/exits. Which would be the best way to achieve this?<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/bedc41359103366af53728a375b82e24?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ndrfloob<br \/>\nerlang otp supervisor gen-server<br \/>\nI&#8217;m working through the Erlang documentation, trying to understand the basics of setting up an OTP gen_server and supervisor. Whenever my gen_server crashes, my supervisor crashes as well. In fact, whenever I have an error on the command line, my supervisor crashes. I expect the gen_server to be restarted when it crashes. I expect command line errors to have no bearing whatsoever on my server components. My supervisor shouldn&#8217;t be crashing at all.The code I&#8217;m working with is a basic &#8220;echo server<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/00230144dde248225dc0a2e228a85131?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\njoshholat<br \/>\nphp bash process supervisor supervisord<br \/>\nPerhaps I&#8217;m misunderstanding with Supervisor does, but perhaps me asking this question will help clear that up. Basically, I have a Supervisor program in my \/etc\/supervisord.conf file that executes a bash script which simply executes a PHP script. I&#8217;ve been able to successfully get that bash script to run from supervisor only upon launch of supervisor. However, isn&#8217;t the point of something like supervisor that it runs that tasks in the background at set intervals or something so that I can know<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/62939494ca1d5e5fbae1274fa42d6123?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nGuandalino<br \/>\nlinux cron process supervisor<br \/>\nActually I&#8217;m using supervisor to monitor a process and restart it when it stops for some reason. The problem is that in case of a supervisor crash the process stops get monitored.So I thought to schedule a cronjob to check supervisor is running, and eventually restart it.The next thing I&#8217;m considering is to get rid of supervisor and check my process directly from the cronjob. I read that sometimes supervisor uses too much memory (to be verified, though).What are the pros in having supervisor VS<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/ba5f7c16f0610adbf4c98ad2dba06281?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJustin Meltzer<br \/>\namazon-ec2 logging node.js debugging supervisor<br \/>\nI&#8217;m using supervisor to start my node.js application on a micro EC2 instance. However, the app only stays running for some time until it eventually shuts down. Not exactly sure how long the app stays running but I&#8217;m guessing for about a few hours or so. Sometimes less. My question is where on the remote server should I be looking in order to debug this kind of issue? I&#8217;m running an Amazon Linux AMI.<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/2c58c49093641ae829e8ad4092be8fa7?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nMue<br \/>\nerlang crash state exit supervisor<br \/>\nWhat&#8217;s a good way to persist state when restarting a crashed process? I have a supervisor in an OTP application what watches several &#8220;subsystem&#8221; gen_servers.For example, one is a &#8220;weather&#8221; subsystem that generates a new weather state every 15 minutes and handles queries for the current state of the weather. (Think the lemonade stand game)If that gen_server crashes, I want it to be restarted, but it should be be restarted with the most recent weather state, not some arbitrary state hardcoded in i<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/71387d425c8c57361696ef709ab9c8a5?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nstemm<br \/>\nerlang otp supervisor gen-server<br \/>\nI&#8217;m very new to OTP, I&#8217;m trying to create simple example to understand supervisor behaviour:Here is simple increment server-module( inc_serv ). -behaviour( gen_server ). -export( [ start\/0, inc\/1, stop\/0 ] ). -export( [ init\/1, handle_call\/3, terminate\/2 ] ).start() -&gt;gen_server:start_link( { local, ?MODULE }, ?MODULE, no_args, [] ).stop() -&gt;gen_server:call( ?MODULE, stop ).inc( Num ) -&gt;gen_server:call( ?MODULE, { num, Num } ).init( no_args ) -&gt;io:format( &#8220;~p~n&#8221;, [ &#8220;Increment server<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/c79937a093ff9e963c563e22cd385f30?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAlexey Romanov<br \/>\nerlang otp supervisor<br \/>\nAre there functions which would allow an OTP process to find the pid of its supervisor?<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/bd047ded051e412f26d183073b70cf16?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nXeno<br \/>\ndjango gunicorn supervisor<br \/>\nI&#8217;ve followed this tutorial twice, but on the second machine that I&#8217;ve run it on I get a supervisor-run gunicorn error. When I tell supervisor to startup gunicorn using:$ sudo supervisorctl start gunicorn gunicorn: ERROR (abnormal termination)The gunicorn_err.log repeats this:Unknown command: &#8216;run_gunicorn&#8217; Type &#8216;manage.py help&#8217; for usage.The supervisor config looks like:[program:gunicorn] command=\/home\/ubuntu\/.virtualenvs\/&lt;VIRTUALENV&gt;\/bin\/python \/home\/ubuntu\/&lt;APPNAME&gt;\/manage.py run_<\/li>\n<\/ul>\n<p id=\"rop\"><small>Originally posted 2014-01-12 20:50:20. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>Sebastian Sastre webserver daemon smalltalk supervisor start-stop-daemon How should I script daemontools superviser?I&#8217;ve started to use D. J. Bernsteins&#8217; daemontools to keep some processes running and is working fine. But now I need to monitor a couple of additional conditions on those processes and I&#8217;ve failed to find good info on how to do that.My [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2446","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2446","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2446"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2446\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2446"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2446"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2446"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}