0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Node-REDのデフォルトの起動ポート番号(1880)を変更する

Posted at

はじめに

macOSで複数のNode-REDを立ち上げる場合、デフォルトの起動ポート番号(1880)の重複が発生します。

Node-REDの変更方法

settings.jsonの中で指定する

1880を1881などへ変更します。

settings.js
    uiPort: process.env.PORT || 1881,

起動時の引数(オプション)で指定する

-p、または、--portで指定します。

$ node node_modules/node-red/red.js -p 1881 -u ./

Node-RED Desktopの変更方法

GUIアプリケーションの環境変数の設定方法です。
~/Library/LaunchAgentsディレクトリにplistファイルを作成します。

$ cd ~/Library/LaunchAgents/
$ vi setenv.NRD_LISTEN_PORT.plist
setenv.NRD_LISTEN_PORT.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>setenv.NRD_LISTEN_PORT</string>
    <key>ProgramArguments</key>
    <array>
      <string>/bin/launchctl</string>
      <string>setenv</string>
      <string>NRD_LISTEN_PORT</string>
      <string>1881</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
  </dict>
</plist>

サービスをロードします。

$ launchctl load ~/Library/LaunchAgents/setenv.NRD_LISTEN_PORT.plist

設定を変更した場合は、サービスをアンロードし、もう一度ロードする必要があります。

$ launchctl unload ~/Library/LaunchAgents/setenv.NRD_LISTEN_PORT.plist

bootstrap、bootoutでも同様に操作可能です。

$ launchctl bootstrap gui/`id -u` ~/Library/LaunchAgents/setenv.NRD_LISTEN_PORT.plist
$ launchctl bootout gui/`id -u` ~/Library/LaunchAgents/setenv.NRD_LISTEN_PORT.plist

参考

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?