ソケットエラーでそのアドレスは既に使用されていると言われる 〜Pyramidを起動しようとして
Pyramidのプロジェクトを起動しようとしたら,こんなエラーが出た.
$ serve development.ini --reload Starting subprocess with file monitor Starting server in PID 1090. Traceback (most recent call last): (略) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 224, in meth return getattr(self._sock,name)(*args) socket.error: [Errno 48] Address already in use
おそらく,前回にPyramidを起動したときのプロセスが残っているのだろう.
ps aux
で,調べようと思っても,大量すぎて見るのもツラい.
というわけで,何か他にいい方法がないかと調べたら,あった.
> Need to close python socket / Find the current running server on my dev environment - Stack Overflow
あって良かったStack Overflow.
lsof
lsofというコマンドなんて始めて知った.無知です.
man lsof
で調べると,
- NAME
- lsof - list open files
- DESCRIPTION
- Lsof revision 4.84 lists on its standard output file information about files opened by processes.An open file may be a regular file, a directory, a block special file, a character special file, an executing text reference, a library, a stream or a network file (Internet socket, NFS file or UNIX domain socket.) A specific file or all the files in a file system may be selected by path. (一部略)
割りと万能そうです.
lsofについては,ここが分かりやすそう.
> lsofの使い方 - プロセスが使用中のファイルを調べる - うまい棒blog
とりあえず,Pyramidで,起動しているプロセスがあることを調べるには,
(デフォルトの状態,ポート番号が6543で起動している場合)
$ lsof -i :6543
として,プロセスIDを調べて,
$ kill <プロセスID>
でいいでしょう.
また賢くなった.だろうか.