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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>What prevents those users from doing a <code>./bin/myapp stop</code>? I mean you can prevent typos by letting the user use distilleries custom commands, which you created. You can obscure the actual shell command from the user by wrapping the distillery commands further into custom shell commands. In the end you still need to send rpc commands to the running erlang 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="62605" 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/how-to-create-and-run-a-custom-task-in-phoenix-like-rake-something-in-ruby/10805/21">Post #20</a>
	                </div>
	            </div>
              <div id="likers-container-62605" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="62605"
                     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="62600" data-post-id="62600">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Mooodi" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Mooodi
                    <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">
								<p>That’s not. What if I have a user whom I delegate this job and whom I don’t want to call anything else but a certain module#method? What will prevent him from calling something else? Even by making a typo.</p>
<p>What if I accidentally call  “MyModule#reset_db2” instead of   “MyModule#reset_db1”? Assuming that  “MyModule#reset_db2” has no task associated with it – it’s merely a module and function, whereas  “MyModule#reset_db1” does.</p>
<p>console won’t prevent such type of mistakes.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="62600" 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/how-to-create-and-run-a-custom-task-in-phoenix-like-rake-something-in-ruby/10805/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-62600" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="62600"
                     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 #19"></div>
  </section>
</div>
    <div class="postbit" id="62168" data-post-id="62168">
  <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
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="Mooodi" data-post="17" data-topic="10805">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/m/b3f665/48.png" class="avatar"> Mooodi:</div>
<blockquote>
<p>That’s a semi-hackery approach, the one similar to editing data directly in database or running REPL on server to patch something in a dirty and fast way, isn’t it?</p>
</blockquote>
</aside>
<p>Not even remotely, that ‘is’ the way to call something in a running system from the system shell.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="62168" 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/how-to-create-and-run-a-custom-task-in-phoenix-like-rake-something-in-ruby/10805/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-62168" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="62168"
                     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="62051" data-post-id="62051">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>No, it’s not hackish. It’s functionally equivalent to doing the <code>remote console</code> approach and typing the command, but it just does it all in one from the unix shell.</p>
<p>Mooodi, I see you have a rails background. As superficially similar as the syntax of Elixir may look to Ruby, things are a whole lot different under the hood. In a distillery release on a server, <code>bin/yourappname</code> is the closest thing to rake you’re going to get. Distillery’s hexdocs are very good and will show you how you can write custom commands for your release (<a href="https://hexdocs.pm/distillery/custom-commands.html" rel="noopener nofollow ugc">https://hexdocs.pm/distillery/custom-commands.html</a>)</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="62051" 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/how-to-create-and-run-a-custom-task-in-phoenix-like-rake-something-in-ruby/10805/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-62051" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="62051"
                     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="62019" data-post-id="62019">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Mooodi" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Mooodi
                    <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 quote-modified" data-username="OvermindDL1" data-post="15" data-topic="10805">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/overminddl1/48/2677_2.png" class="avatar"> OvermindDL1:</div>
<blockquote>
<p>Your server like bin/&lt;name&gt; has an RPC command for calling functions straight, like bin/&lt;name&gt; rpc The.Module function_to_call args…</p>
</blockquote>
</aside>
<p>That’s a semi-hackery approach, the one similar to editing data directly in database or running REPL on server to patch something in a dirty and fast way, isn’t it?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="62019" 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/how-to-create-and-run-a-custom-task-in-phoenix-like-rake-something-in-ruby/10805/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-62019" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="62019"
                     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="62018" data-post-id="62018">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Mooodi" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Mooodi
                    <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">
								<p>I’m using distillery.<br>
I’ll try that out, thx.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="62018" 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/how-to-create-and-run-a-custom-task-in-phoenix-like-rake-something-in-ruby/10805/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-62018" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="62018"
                     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="61888" data-post-id="61888">
  <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
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Your server like <code>bin/&lt;name&gt;</code> has an RPC command for calling functions straight, like <code>bin/&lt;name&gt; rpc The.Module function_to_call args...</code>.</p>
<p>So you make the function in your system, then you can call it like that.  Quite simple and easily wrappable into single-line scripts.  <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="61888" data-batch-url="/posts/batch_likers">
                        2
                      </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/how-to-create-and-run-a-custom-task-in-phoenix-like-rake-something-in-ruby/10805/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-61888" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="61888"
                     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="61841" data-post-id="61841">
  <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">
								<p><code>rake</code> is a ruby tool and independant from phoenix, elixir or whatnot. If you want to use <code>rake</code> you need to install it.</p>
<p>If though you want to run maintanance functions, then just create them in your application, eg:</p>
<pre data-code-wrap="ex"><code class="lang-ex">defmodule MyApp.Maintanance do
  def foo(), do: :bar
end
</code></pre>
<p>Remote-Shell into your app:</p>
<pre><code class="lang-plaintext">$ iex --remsh your@node --cookie $your_cookie --name your@ip
[elixir header]
iex(1)&gt; MyApp.Maintanace.foo()
:bar
</code></pre>
<p>Well, at least roughly. Can’t test right now, since I’ve no elixir machine, but thats the rough theory.</p>
<p>If you use destillery, you can use this example from the docs, <a href="https://hexdocs.pm/distillery/running-migrations.html#content" rel="nofollow">explaining how to run migrations</a> and <strong>change it that it suites your needs</strong>.</p>
<p>Basically it involves these steps:</p>
<ol>
<li>Write <a href="https://hexdocs.pm/distillery/running-migrations.html#migration-module" rel="nofollow">maintance functionality</a> in your app</li>
<li>write a <a href="https://hexdocs.pm/distillery/running-migrations.html#custom-command" rel="nofollow">shell script</a> which wraps your command</li>
<li><a href="https://hexdocs.pm/distillery/running-migrations.html#tying-it-all-together" rel="nofollow">register a subcommand</a> in your release config</li>
</ol>
<p>Also as far as I remember, destillery has a command for a shell built-in: <code>myapp shell</code> (after SSHing into your server) should open up an iex prompt which runs in the context of your application.</p>
<hr>
<p><strong>edit</strong></p>
<p>It’s not <code>shell</code>, it’s <code>remote_console</code>:</p>
<blockquote>
<p>Once started, you can connect a shell to the running release with <code>bin/&lt;name&gt; remote_console</code> or <code>bin/&lt;name&gt; attach</code>, though I would avoid the latter unless you have good reason to use it, as exiting with <kbd>CTRL</kbd>+<kbd>C</kbd> will kill the running node, while doing so with <code>remote_console</code> will simply exit the shell.</p>
</blockquote>
<p>From <a href="https://github.com/bitwalker/distillery/blob/master/docs/Walkthrough.md" rel="nofollow">https://github.com/bitwalker/distillery/blob/master/docs/Walkthrough.md</a></p>
<hr>
<p><strong>edit2</strong></p>
<p>And if you are not using distillery, but something else to build your release, you should tell, then we can answer more tailored to your release tool.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="61841" data-batch-url="/posts/batch_likers">
                        2
                      </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/how-to-create-and-run-a-custom-task-in-phoenix-like-rake-something-in-ruby/10805/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-61841" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="61841"
                     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="61840" data-post-id="61840">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>It was an example <img src="https://forum.elixirforum.com/images/emoji/apple/wink.png?v=15" title=":wink:" class="emoji" alt=":wink:" loading="lazy" width="20" height="20"> You can do it as we already explained you how, just make sure that any part of your app that you want to use, it’s started.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="61840" 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/how-to-create-and-run-a-custom-task-in-phoenix-like-rake-something-in-ruby/10805/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-61840" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="61840"
                     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="61839" data-post-id="61839">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Mooodi" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Mooodi
                    <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">
								<p>I didn’t say “migrations”. I said - task. I want to login to my server via ssh and run a task in the terminal, the same way I’d do in ruby – “rake my_task”</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="61839" 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/how-to-create-and-run-a-custom-task-in-phoenix-like-rake-something-in-ruby/10805/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-61839" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="61839"
                     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>
</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/10805/load_more?page=3">Load more posts (10 remaining)</a>
</div></template></turbo-stream>