LoginSignup
0
0

More than 5 years have passed since last update.

powが使えなくて詰まる(解決編)・・・、が解決してなかった問題

Last updated at Posted at 2015-08-27

powが使えなくて詰まる(解決編)・・・、が解決してなかった問題

ポートに20559を指定しないとまた動かなくなりました・・・。
再インストールして色々と確認です。

$ launchctl list | grep -i pow
PID    status   Label
407     0       cx.pow.powd
-       0       com.apple.powerchime

cx.pow.firewallのデーモンが動いてないみたい、
っと思いきやどうやらデーモンにも種類があるようです。
参考サイト

launchctl listコマンドででてくるものはroot権限を必要としないもので、
root権限で動いているデーモン達をみたければsudo launchctl listコマンドで見られるようです。

$ sudo launchctl list | grep -i pow
PID    status   Label
48  0   com.apple.powerd
-   0   cx.pow.firewall
-   0   com.apple.powerd.swd

PIDに番号があるものは起動していて、statusが0なら正常のようです。
cx.pow.firewallのPIDがないので動いていないことが確認できました。
参考サイト

いつものpowder configコマンドで確認。

dstPort      80
httpPort     20559
dnsPort      20560
timeout      900
workers      2
domains      dev
extDomains

ここのdstPortのポート番号は、

~/.powconfig
export POW_DOMAINS=dev
export POW_DST_PORT=80

のファイルで変更できるようです。
なくてもデフォルト値が入るので問題ないです。

最後にcx.pow.firewall.plistデーモンの確認。

/Library/LaunchDaemons/cx.pow.firewall.plist

cx.pow.firewall.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>cx.pow.firewall</string>
        <key>ProgramArguments</key>
        <array>
                <string>/bin/sh</string>
                <string>-c</string>
                <string>
                  sysctl -w net.inet.ip.forwarding=1;
                  echo "rdr pass proto tcp from any to any port {80,20559} -> 127.0.0.1 port 20559" | pfctl -a "com.apple/250.PowFirewall" -Ef -
                </string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>UserName</key>
        <string>root</string>
</dict>
</plist>

"rdr pass proto tcp from any to any port {80,20559} -> 127.0.0.1 port 20559"
ここはdstPortと同じポートを指していれば大丈夫っぽいです。

cx.pow.firewallデーモンを起こす

参考サイト

launchctl の使用例
OS ブート時に launchd が load しているジョブは、root 権限で操作する必要がある。
LaunchDaemon の起動方法
launchctl コマンドで launchd.plist ファイルをロードする。
load, unload するときは launchd.plist の指定をファイルパス(フルパス)で行う必要がある。

ここに当てはまると思うので、
$ sudo launchctl load /Library/LaunchDaemons/cx.pow.firewall.plist
を実行。

/Library/LaunchDaemons/cx.pow.firewall.plist: Operation already in progress
ん〜、もう動いてるよ的な意味?ですかね。
再度確認。

$ sudo launchctl list | grep -i pow
PID    status   Label
48  0   com.apple.powerd
-   0   cx.pow.firewall
-   0   com.apple.powerd.swd

PIDが付いてないので準備はできていても、動いてないっぽいですね。
powder openしてもポート20559をつけないと動かず・・・。

ちょっと時間切れになってしまったので、
launchctlコマンドについて次は調べたいと思います。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0