<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="47263" data-post-id="47263">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="OvermindDL1" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/OvermindDL1/120/2677_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  OvermindDL1
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="aboroska" data-post="11" data-topic="7620">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/aboroska/48/1059_2.png" class="avatar"> aboroska:</div>
<blockquote>
<p>The main advantage of the heart method is that it is OS independent.</p>
</blockquote>
</aside>
<p>True, but systemd here at work communicates to and logs to a central logging system off-server and it is useful to see all the times it goes down, starts eating too much cpu, etc… etc…  <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
<aside class="quote no-group" data-username="aboroska" data-post="11" data-topic="7620">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/aboroska/48/1059_2.png" class="avatar"> aboroska:</div>
<blockquote>
<p>Better option to stop the VM would be to call init:stop() from a remote node as described here for example</p>
</blockquote>
</aside>
<p>That is what my systemd service script does.  ^.^</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="47263" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/pidfile-create-and-manage-a-pid-file-from-the-beam-process/7620/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-47263" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="47263"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="47291" data-post-id="47291">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="ijunaidfarooq" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ijunaidfarooq/120/1532_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  ijunaidfarooq
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Just because there is a SystemD job written in the question , So anyone might help me as well.</p>
<p>I have this Service Unit.</p>
<pre><code>[Unit]
Description=Evercam Media
After=network.target

[Service]
User=root
Group=root
WorkingDirectory=/
ExecStart=/opt/evercam_media/bin/evercam_media start
ExecStop=/opt/evercam_media/bin/evercam_media stop

#Restart=always

[Install]
WantedBy=multi-user.target
</code></pre>
<p>And it only giving me</p>
<p>this error always</p>
<pre><code>Aug 23 08:28:30 Ubuntu-1604-xenial-64-minimal systemd[1]: Started Evercam Media.
Aug 23 08:28:31 Ubuntu-1604-xenial-64-minimal evercam_media[30064]: Starting up
Aug 23 08:28:31 Ubuntu-1604-xenial-64-minimal evercam_media[30009]: Node 'evercam_media@Ubuntu-1604-xenial-64-minimal' not responding to pings.
Aug 23 08:28:31 Ubuntu-1604-xenial-64-minimal systemd[1]: evercam_server.service: Control process exited, code=exited status=1
Aug 23 08:28:32 Ubuntu-1604-xenial-64-minimal systemd[1]: evercam_server.service: Unit entered failed state.
Aug 23 08:28:32 Ubuntu-1604-xenial-64-minimal systemd[1]: evercam_server.service: Failed with result 'exit-code'.
</code></pre>
<p>Can you point me the issue in this?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="47291" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/pidfile-create-and-manage-a-pid-file-from-the-beam-process/7620/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-47291" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="47291"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="47355" data-post-id="47355">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="OvermindDL1" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/OvermindDL1/120/2677_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  OvermindDL1
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="ijunaidfarooq" data-post="13" data-topic="7620">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ijunaidfarooq/48/1532_2.png" class="avatar"> ijunaidfarooq:</div>
<blockquote>
<pre data-code-wrap="elixir"><code class="lang-elixir">Aug 23 08:28:30 Ubuntu-1604-xenial-64-minimal systemd[1]: Started Evercam Media.
Aug 23 08:28:31 Ubuntu-1604-xenial-64-minimal evercam_media[30064]: Starting up
Aug 23 08:28:31 Ubuntu-1604-xenial-64-minimal evercam_media[30009]: Node 'evercam_media@Ubuntu-1604-xenial-64-minimal' not responding to pings.
Aug 23 08:28:31 Ubuntu-1604-xenial-64-minimal systemd[1]: evercam_server.service: Control process exited, code=exited status=1
Aug 23 08:28:32 Ubuntu-1604-xenial-64-minimal systemd[1]: evercam_server.service: Unit entered failed state.
Aug 23 08:28:32 Ubuntu-1604-xenial-64-minimal systemd[1]: evercam_server.service: Failed with result 'exit-code'.
</code></pre>
</blockquote>
</aside>
<p>That indicates to me that the <code>evercam_media start</code> command is failing.  Have you tried launching it manually?  Does it require to be started after something else other than <code>After=network.target</code> like the USB system or something?</p>
<p>EDIT:  Oh wait, this is a BEAM VM?</p>
<p>Since you do not have a <code>Type</code> specified then it defaults to <code>Simple</code> as I recall, meaning it expects the program to persist, not fork.  You need to use <code>Type=forking</code> as in my example.  You really should copy and use my example in that case.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="47355" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/pidfile-create-and-manage-a-pid-file-from-the-beam-process/7620/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-47355" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="47355"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #13"></div>
  </section>
</div>
    <div class="postbit" id="47365" data-post-id="47365">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="ijunaidfarooq" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ijunaidfarooq/120/1532_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  ijunaidfarooq
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Actually , I converted the Upstart Job to SystemD Unit, So thats why I added that <code>After=network.target</code> thing..</p>
<p>Yes Its starts manually..</p>
<p>Okay I am going to try with <code>Type=forking</code> and with your example,</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="47365" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/pidfile-create-and-manage-a-pid-file-from-the-beam-process/7620/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-47365" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="47365"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #14"></div>
  </section>
</div>
    <div class="postbit" id="47386" data-post-id="47386">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="ijunaidfarooq" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ijunaidfarooq/120/1532_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  ijunaidfarooq
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Okay your snippet worked and in this way</p>
<pre><code>LimitNOFILE 1000000 1000000

[Unit]
Description=Evercam Media
After=network.target

[Service]
Type=forking
User=root
Group=root
WorkingDirectory=/opt/evercam_media
ExecStart=/opt/evercam_media/bin/evercam_media start
ExecStop=/opt/evercam_media/bin/evercam_media stop
Restart=always
RestartSec=5
Environment=LANG=en_US.UTF-8
SyslogIdentifier=evercam_media

[Install]
WantedBy=multi-user.target
</code></pre>
<p>I have few concerns which I want to share with you, In case you see few things wrong here or may you can help in any case..</p>
<p>We were on Ubuntu 14.04 and was using upstart job, which was like</p>
<pre><code>description  "evercam_media"
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
limit nofile 1000000 1000000

respawn
chdir /
setuid {{user_name}}
setgid {{user_name}}

env HOME=/home/{{user_name}}
env LANG=en_US.UTF-8
env LANGUAGE=en_US:en
env LS_ALL=en_US.UTF-8
env ERL_MAX_PORTS=10240
env ERL_MAX_ETS_TABLES=5000
{% for key, value in env_vars.items() %}
env {{key.upper()}}={{value}}
{% endfor %}

exec watch -n1 '/usr/local/bin/run_evercam_media.sh'

post-stop exec sudo pkill beam
</code></pre>
<p>The former developer who created the upstart job, He used <code>watch</code> with seconds values as <code>1</code> , just to watch the script every one second. and in SH script, he was doing something</p>
<pre><code>if ! (ps aux | grep evercam_media/bin/evercam_media | grep -v grep &gt; /dev/null); then
   /opt/evercam_media/bin/evercam_media start
fi
</code></pre>
<p>for example, the evercam media have stopped due to some reasons it will start it again. and watching it every one second.</p>
<p>What if the above service unit get failed due to some reason? Will it restart it self? I have seen <code>Restart=on-failure</code> thing as well, do you think it will help?</p>
<p>Also big question: ENV variables, I dont see anywhere you pointed about ENV variables?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="47386" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/pidfile-create-and-manage-a-pid-file-from-the-beam-process/7620/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-47386" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="47386"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #15"></div>
  </section>
</div>
    <div class="postbit" id="47390" data-post-id="47390">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="OvermindDL1" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/OvermindDL1/120/2677_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  OvermindDL1
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="ijunaidfarooq" data-post="16" data-topic="7620">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ijunaidfarooq/48/1532_2.png" class="avatar"> ijunaidfarooq:</div>
<blockquote>
<p>The former developer who created the upstart job, He used watch with seconds values as 1 , just to watch the script every one second. and in SH script, he was doing something</p>
</blockquote>
</aside>
<p>That looks horrifying!  That is quite an extra load on the server for no reason…  He’s spawning an entire BEAM VM instance every second just to ping it?!  o.O</p>
<aside class="quote no-group" data-username="ijunaidfarooq" data-post="16" data-topic="7620">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ijunaidfarooq/48/1532_2.png" class="avatar"> ijunaidfarooq:</div>
<blockquote>
<p>What if the above service unit get failed due to some reason? Will it restart it self? I have seen Restart=on-failure thing as well, do you think it will help?</p>
</blockquote>
</aside>
<p>If you use <code>Restart=always</code> as in my script then it will always restart, including on failure.  Only way it will not be restarted is it you <code>systemctl stop ...</code> it, and even then it will be restarted on next reboot unless you <code>systemctl disable ...</code> it too.  ^.^</p>
<aside class="quote no-group" data-username="ijunaidfarooq" data-post="16" data-topic="7620">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ijunaidfarooq/48/1532_2.png" class="avatar"> ijunaidfarooq:</div>
<blockquote>
<p>Also big question: ENV variables, I dont see anywhere you pointed about ENV variables?</p>
</blockquote>
</aside>
<p>I had two in my script above:</p>
<pre data-code-wrap="systemd"><code class="lang-systemd">Environment=PORT=3000
Environment=LANG=en_US.UTF-8
</code></pre>
<p>You can of course define your own, or you can import an external file too (see the systemd service file spec).  <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="47390" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/pidfile-create-and-manage-a-pid-file-from-the-beam-process/7620/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-47390" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="47390"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #16"></div>
  </section>
</div>
    <div class="postbit" id="47400" data-post-id="47400">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="ijunaidfarooq" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ijunaidfarooq/120/1532_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  ijunaidfarooq
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<blockquote>
<p>That looks horrifying! That is quite an extra load on the server for no reason… He’s spawning an entire BEAM VM instance every second just to ping it?! o.O</p>
</blockquote>
<p>Nope, He is not doing that, new BEAM VM instance only get initiated if <code>evercam_media</code> process is not found through sh script.</p>
<p>Okay thanks for your help. <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="47400" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/pidfile-create-and-manage-a-pid-file-from-the-beam-process/7620/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-47400" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="47400"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #17"></div>
  </section>
</div>
    <div class="postbit" id="47472" data-post-id="47472">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="OvermindDL1" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/OvermindDL1/120/2677_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  OvermindDL1
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="ijunaidfarooq" data-post="18" data-topic="7620">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ijunaidfarooq/48/1532_2.png" class="avatar"> ijunaidfarooq:</div>
<blockquote>
<p>Nope, He is not doing that, new BEAM VM instance only get initiated if evercam_media process is not found through sh script.</p>
</blockquote>
</aside>
<p>Ah, missed that, thought it was pinging with the VM.  ^.^;</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="47472" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/pidfile-create-and-manage-a-pid-file-from-the-beam-process/7620/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-47472" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="47472"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #18"></div>
  </section>
</div>
    <div class="postbit" id="84479" data-post-id="84479">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="happysalada" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/happysalada/120/10803_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  happysalada
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I can start the application without problem, but when I try to launch it with systemd it keeps failing and restarting for some reason.<br>
Here are the logs</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">un 08 10:00:15 union-staging systemd[1]: Starting Union Servers...
-- Subject: Unit union.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit union.service has begun starting up.
Jun 08 10:00:16 union-staging union[8741]: ==&gt; Generated sys.config in /test/union/var
Jun 08 10:00:19 union-staging union[8998]: ==&gt; Generated sys.config in /test/union/var
Jun 08 10:00:19 union-staging union[9530]: Starting up
Jun 08 10:00:20 union-staging systemd[1]: union.service: control process exited, code=exited status=1
Jun 08 10:00:20 union-staging union[8998]: Node union@127.0.0.1 is not running!
Jun 08 10:00:20 union-staging systemd[1]: Unit union.service entered failed state.
Jun 08 10:00:20 union-staging systemd[1]: union.service failed.
Jun 08 10:00:25 union-staging systemd[1]: union.service holdoff time over, scheduling restart.
Jun 08 10:00:25 union-staging systemd[1]: Started Union Servers.
-- Subject: Unit union.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit union.service has finished starting up.
--
lines 1190-1211/1247 98%
-- The start-up result is done.
Jun 08 10:00:15 union-staging systemd[1]: Starting Union Servers...
-- Subject: Unit union.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit union.service has begun starting up.
Jun 08 10:00:16 union-staging union[8741]: ==&gt; Generated sys.config in /test/union/var
Jun 08 10:00:19 union-staging union[8998]: ==&gt; Generated sys.config in /test/union/var
Jun 08 10:00:19 union-staging union[9530]: Starting up
Jun 08 10:00:20 union-staging systemd[1]: union.service: control process exited, code=exited status=1
Jun 08 10:00:20 union-staging union[8998]: Node union@127.0.0.1 is not running!
Jun 08 10:00:20 union-staging systemd[1]: Unit union.service entered failed state.
Jun 08 10:00:20 union-staging systemd[1]: union.service failed.
Jun 08 10:00:25 union-staging systemd[1]: union.service holdoff time over, scheduling restart.
Jun 08 10:00:25 union-staging systemd[1]: Started Union Servers.
-- Subject: Unit union.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit union.service has finished starting up.
</code></pre>
<p>Here is my systemd config</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">[Unit]
Description=Union Servers
After=network-online.target
[Service]
Type=forked
User=root
Group=root
WorkingDirectory=/test/union
ExecStart=/test/union/bin/union start
ExecReload=/test/union/bin/union reload_config
ExecStop=/test/union/bin/union stop
PIDFile=/test/union/union.prod.pid
Restart=always
RestartSec=5
Environment=PORT=4000
Environment=LANG=en_US.UTF-8
SyslogIdentifier=union
[Install]
WantedBy=multi-user.target
</code></pre>
<p>The system variable I use is<br>
<code>PIDFILE="./union.prod.pid"</code><br>
Here is my mix file</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">[
      {:phoenix, "~&gt; 1.3.0"},
      {:phoenix_pubsub, "~&gt; 1.0"},
      {:phoenix_ecto, "~&gt; 3.2"},
      {:postgrex, "&gt;= 0.0.0"},
      {:phoenix_html, "~&gt; 2.10"},
      {:gettext, "~&gt; 0.13.1"},
      {:cowboy, "~&gt; 1.0"},
      {:ex_admin, github: "sublimecoder/ex_admin"},
      {:timex, "~&gt; 3.2", override: true},
      {:coherence, "~&gt; 0.5"},
      {:cloudex, "~&gt; 1.0"},
      {:number, "~&gt; 0.5.4"},
      {:turbolinks, "~&gt; 0.3.2"},
      {:ecto_enum, "~&gt; 1.1"},
      {:jason, "~&gt; 1.0"},
      {:absinthe, "~&gt; 1.4.2"},
      {:absinthe_plug, "~&gt; 1.4.0"},

      # Instrumentation
      {:observer_cli, "~&gt; 1.3.1"},
      {:exprof, "~&gt; 0.2.1"},
      {:eflame, "~&gt; 1.0"},
      {:sentry, "~&gt; 6.2.0"},
      {:prometheus_ex, "~&gt; 1.0"},
      {:prometheus_ecto, "~&gt; 1.0"},
      {:prometheus_phoenix, "~&gt; 1.2"},
      {:prometheus_plugs, "~&gt; 1.0"},
      {:prometheus_process_collector, "~&gt; 1.1"},

      # dev dependencies
      {:phoenix_live_reload, "~&gt; 1.0", only: :dev},
      {:ex_doc, "~&gt; 0.18", only: :dev, runtime: false},
      {:credo, "~&gt; 0.8", only: [:dev, :test], runtime: false},
      {:dialyxir, "~&gt; 0.5.0", only: [:dev], runtime: false},

      # release
      {:edeliver, "~&gt; 1.5.0"},
      {:distillery, "~&gt; 1.5", runtime: false},
      {:pid_file, "~&gt; 0.1.0"},
      {:conform, "~&gt; 2.2"}
    ]
</code></pre>
<p>I’m not really sure what I’m doing wrong.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="84479" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/pidfile-create-and-manage-a-pid-file-from-the-beam-process/7620/21">Post #20</a>
	                </div>
	            </div>
              <div id="likers-container-84479" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="84479"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #20"></div>
  </section>
</div>
    <div class="postbit" id="84481" data-post-id="84481">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="NobbZ" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/NobbZ/120/27235_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  NobbZ
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="happysalada" data-post="21" data-topic="7620">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/happysalada/48/10803_2.png" class="avatar"> happysalada:</div>
<blockquote>
<p>The system variable I use is<br>
<code>PIDFILE="./union.prod.pid"</code></p>
</blockquote>
</aside>
<p>Use an absolute path, just to be sure.</p>
<p>Also you haven’t shown your configuration of the pid_file-application.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="84481" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/pidfile-create-and-manage-a-pid-file-from-the-beam-process/7620/22">Post #21</a>
	                </div>
	            </div>
              <div id="likers-container-84481" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="84481"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #21"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/7620/load_more?page=3">Load more posts (22 remaining)</a>
</div></template></turbo-stream>