jekyll build from Action f21e5839ed9b95e4837e69015a4cc9039cc7e6f5

This commit is contained in:
sahinakkaya 2023-01-16 15:57:32 +00:00
parent 9d22f07e89
commit 08326b8019
4 changed files with 19 additions and 15 deletions

View File

@ -467,12 +467,14 @@ restart_scripts<span class="o">(){</span>
<span class="c"># for each script in the list</span>
<span class="k">for </span>script <span class="k">in</span> <span class="s2">"</span><span class="k">${</span><span class="nv">scripts_to_be_executed</span><span class="p">[@]</span><span class="k">}</span><span class="s2">"</span>
<span class="k">do</span>
<span class="c"># run the script and store its pid.</span>
<span class="c"># '&amp;' at the end of command is important otherwise</span>
<span class="c"># the script will block until its execution is finished.</span>
<span class="nv">$script</span> &amp;
<span class="nv">pid</span><span class="o">=</span><span class="nv">$!</span>
pids+<span class="o">=(</span><span class="s2">"</span><span class="nv">$pid</span><span class="s2">"</span><span class="o">)</span>
<span class="c"># Run the script and store its pid.</span>
<span class="c"># note the '&amp;' at the end of command. Without it the script will</span>
<span class="c"># block until its execution is finished. Also we are putting it</span>
<span class="c"># into braces because we want to create a process group so that</span>
<span class="c"># killing this pid will end all the grandchilds.</span>
<span class="c"># (useful if you have pipes (|) or other &amp;'s in your script!)</span>
<span class="o">(</span><span class="nv">$script</span><span class="o">)</span> &amp;
pids+<span class="o">=(</span><span class="s2">"</span><span class="nv">$!</span><span class="s2">"</span><span class="o">)</span>
<span class="k">done</span>
<span class="o">}</span>

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.2.1">Jekyll</generator><link href="https://sahinakkaya.dev/feed.xml" rel="self" type="application/atom+xml" /><link href="https://sahinakkaya.dev/" rel="alternate" type="text/html" /><updated>2023-01-16T11:21:01+00:00</updated><id>https://sahinakkaya.dev/feed.xml</id><title type="html">Şahin Akkayas Personal Page</title><subtitle>Şahin Akkaya's personal blog - a perfectionist who likes to tinker everything until it is just right. Get ready to find some sweet tips that will boost your productivity and make you fall in love with your computer.</subtitle><author><name>Şahin Akkaya</name></author><entry><title type="html">Hot-Reload Long Running Shell Scripts (feat. trap / kill)</title><link href="https://sahinakkaya.dev/2023/01/15/hot-reloading-with-trap-and-kill.html" rel="alternate" type="text/html" title="Hot-Reload Long Running Shell Scripts (feat. trap / kill)" /><published>2023-01-15T21:48:08+00:00</published><updated>2023-01-15T21:48:08+00:00</updated><id>https://sahinakkaya.dev/2023/01/15/hot-reloading-with-trap-and-kill</id><content type="html" xml:base="https://sahinakkaya.dev/2023/01/15/hot-reloading-with-trap-and-kill.html">&lt;h2 id=&quot;trap-them-and-kill-them&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;trap&lt;/code&gt; them and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;kill&lt;/code&gt; them!&lt;/h2&gt;
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.2.1">Jekyll</generator><link href="https://sahinakkaya.dev/feed.xml" rel="self" type="application/atom+xml" /><link href="https://sahinakkaya.dev/" rel="alternate" type="text/html" /><updated>2023-01-16T15:57:30+00:00</updated><id>https://sahinakkaya.dev/feed.xml</id><title type="html">Şahin Akkayas Personal Page</title><subtitle>Şahin Akkaya's personal blog - a perfectionist who likes to tinker everything until it is just right. Get ready to find some sweet tips that will boost your productivity and make you fall in love with your computer.</subtitle><author><name>Şahin Akkaya</name></author><entry><title type="html">Hot-Reload Long Running Shell Scripts (feat. trap / kill)</title><link href="https://sahinakkaya.dev/2023/01/15/hot-reloading-with-trap-and-kill.html" rel="alternate" type="text/html" title="Hot-Reload Long Running Shell Scripts (feat. trap / kill)" /><published>2023-01-15T21:48:08+00:00</published><updated>2023-01-15T21:48:08+00:00</updated><id>https://sahinakkaya.dev/2023/01/15/hot-reloading-with-trap-and-kill</id><content type="html" xml:base="https://sahinakkaya.dev/2023/01/15/hot-reloading-with-trap-and-kill.html">&lt;h2 id=&quot;trap-them-and-kill-them&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;trap&lt;/code&gt; them and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;kill&lt;/code&gt; them!&lt;/h2&gt;
&lt;p&gt;There is a beautiful command in Linux called &lt;a href=&quot;https://man7.org/linux/man-pages/man1/trap.1p.html&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;trap&lt;/code&gt;&lt;/a&gt; which &lt;em&gt;trap&lt;/em&gt;s signals and let you run specific commands when they invoked. There is also good ol &lt;a href=&quot;https://man7.org/linux/man-pages/man1/kill.1.html&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;kill&lt;/code&gt;&lt;/a&gt; command which not only kills processes but allows you to specify a signal to send. By combining these two, you can run specific functions from your scripts any time!&lt;/p&gt;
&lt;h3 id=&quot;basic-example&quot;&gt;Basic Example&lt;/h3&gt;
@ -146,12 +146,14 @@ restart_scripts&lt;span class=&quot;o&quot;&gt;(){&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# for each script in the list&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;script &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;scripts_to_be_executed&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[@]&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# run the script and store its pid.&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# '&amp;amp;' at the end of command is important otherwise&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# the script will block until its execution is finished.&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$script&lt;/span&gt; &amp;amp;
&lt;span class=&quot;nv&quot;&gt;pid&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$!&lt;/span&gt;
pids+&lt;span class=&quot;o&quot;&gt;=(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$pid&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# Run the script and store its pid.&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# note the '&amp;amp;' at the end of command. Without it the script will&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# block until its execution is finished. Also we are putting it&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# into braces because we want to create a process group so that&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# killing this pid will end all the grandchilds.&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# (useful if you have pipes (|) or other &amp;amp;'s in your script!)&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$script&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &amp;amp;
pids+&lt;span class=&quot;o&quot;&gt;=(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$!&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;done&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

View File

@ -55,6 +55,6 @@
</url>
<url>
<loc>https://sahinakkaya.dev/assets/docs/resume.pdf</loc>
<lastmod>2023-01-16T11:20:54+00:00</lastmod>
<lastmod>2023-01-16T15:57:23+00:00</lastmod>
</url>
</urlset>