スキップしてメイン コンテンツに移動

Node.js を動かし続けるため、Forever を使ってみてダメだったので、nohup node にしてみた!

cron に1分おきでサイトを確認して落ちたらForeverで再起動してみたが、大量のNodeプロセスが残されたため、メモリ足りなくなってサーバ自体が落ちた><
だから、下記のように変えてみた。

sudo crontab -e で下記の一行を追加

0-59/1 * * * *   /bin/bash /home/username/site_3000_alive.sh

site_3000_alive.sh 
--------------------------
#!/bin/bash

#================================================================
# check web server
#
# wget option
# -nv : no verbose 
# -S  : print server response
# -t  : tries number 
# -T  : timeout seconds
# --spider             : don't download anything.
# --http-user=USER     : set http user to USER.
# --http-password=PASS : set http password to PASS.
#
# grep option
# -c : only print a count of matching lines per FILE
#================================================================

# parameter
URL="http://win.site.net:3000"
TRY=1
TIMEOUT=60

# check
check=`/usr/bin/wget -nv -S --spider -t $TRY -T $TIMEOUT $URL 2>&1| /bin/grep -c "200 OK"`

if [ $check -lt 1 ]
then
/usr/bin/nohup /usr/local/bin/node /home/username/node/node-memo-demo/app.js > nodememo.log &
fi

コメント

このブログの人気の投稿

Excel Power Query 英数字の全角から半角への変換

最近仕事上でExcelのPower Queryを始めました。しかし、英数字の全角から半角への変換関数がないため、下記のサイトを参考して、 作っちゃいました。  https://qiita.com/baku2san/items/8041d0259fe0db680e7e https://www.yoheim.net/blog.php?q=20191101 (original as text) as text =&gt; let    originalText = Text.Combine({original, ""}),    replaceResult =  Web.Page("<script>var originalText="&"'"&originalText&"'"&";var result=originalText.replace(/[A-Za-z0-9]/g, function(s) {return String.fromCharCode(s.charCodeAt(0) - 0xFEE0);});document.write(result);</script>")       [Data]{0}[Children]{0}[Children],    result = if (List.Count(replaceResult) &lt;= 1) then    {        "" as text // 変換して何も残らない場合    } else if (replaceResult{1}[Text]{0} = null) then    {       originalText   as text// 何も見つからない場合    }  else {       replaceResult{1}[Text]{0} as text    } in     result{0}  

自己流思い付き

 長年契約してきたさくらインターネットのVPSに稼働しているWordpressが何らかのものに削除されました。幸い残したいものはこのブログに移したので、あまり困ったことはありませんでした。もうVPSを解約しようと思いますが、今年の11月までの契約なので、正直って迷っております。  職場のホームページサーバがMacmini上のピュアDebianなので、実験台としてVPSを契約したのですが、もう実験しないし、解約してもよいだと思います。   このブログもこれをきっかけにタイトルを変えました。

余裕ですかね。

  いまの自分はやることが多いが、意外と慌てず一歩一歩現場と歩んでいき、地道にデータ入力から可視化までの利便性、完全性と正確性を追求する余裕が出ております。SpotfireというBIツールにハマり、人に使い方を教えながらもまたその恩恵を受けているといういい循環も大きいですね。大体自分のようなポストにいる人たちはあまりプログラムを書く余裕もないだが、自分は幸せのほうと思います。