GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

Untitled attachment

Download link

Notices where this attachment appears

  1. Embed this notice
    zunda (zundan@mastodon.zunda.ninja)'s status on Monday, 25-Dec-2023 08:10:13 JST zunda zunda
    in reply to

    僕の使っているコマンドラインツールの #ひかえめなアドベントカレンダー2023 12月24日分はpsとlsofです。プロセスの様子と開いているファイルなどを見てみます。

    ここでは、herokuコマンドを起動してみます。

    $ heroku pg:psql -a app-name

    psコマンドで関連するプロセスのIDを探します。

    $ ps a | grep heroku | grep -v grep
    3677 pts/0 S+ 0:00 bash /usr/bin/heroku pg:psql
    3684 pts/0 Sl+ 0:01 /usr/lib/heroku/bin/node /usr/lib/heroku/bin/run pg:psql

    fオプションで親子関係を、wオプションで端末の幅を越えてコマンドラインを表示してもらいます。nodeがスクリプトを実行し、ローカルでpsqlコマンドを実行しています。

    $ ps afw
    PID TTY STAT TIME COMMAND
    :
    3104 pts/0 Ss 0:00 bash
    3677 pts/0 S+ 0:00 \_ bash /usr/bin/heroku pg:psql
    3684 pts/0 Sl+ 0:01 \_ /usr/lib/heroku/bin/node /usr/lib/heroku/bin/run pg:psql
    3695 pts/0 S+ 0:00 \_ /usr/lib/postgresql/14/bin/psql --set PROMPT1=app-name::DATABASE%R%# --set PROMPT2=
    :

    lsofコマンドでpsqlプロセスを探すとデータベースサーバとのTCP接続が見えます。

    $ lsof -i tcp | grep 3695
    psql 3695 zunda 3u IPv4 47834 0t0 TCP misoan:36458->postgres.example.com:postgresql (ESTABLISHED)

    Private Spaceアプリだともっと複雑でたのしいよ!!

    In conversation Monday, 25-Dec-2023 08:10:13 JST from mastodon.zunda.ninja permalink
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.