RocketChat / Rocket.Chat.RaspberryPi

Run a private social network on your Pi for iPhone and Android devices !
MIT License
337 stars 59 forks source link

ROOT_URL env variable does not change site URL #20

Closed GorgiAstro closed 4 years ago

GorgiAstro commented 7 years ago

Hello,

I have installed Rocket.Chat on my Raspberry Pi 3 (running up-to-date Raspbian Jessie) through the DPlatform installer. When I have installed it, the Raspberry Pi had a different IP address (192.168.178.49) than it has now (192.168.2.2).

The URL of Rocket.Chat is supposed to be defined at startup by the environment variable ROOT_URL. However, the systemd logs show that Rocket.Chat actually starts with the Site URL 192.168.178.49. On my laptop with the web interface or the Windows Rocket.Chat client, it is not an issue, but it is an issue for the Android and iOS clients: if the IP of the Raspberry Pi does not match the rocket.chat site URL, these clients do not want to connect.

In the systemd service file, this variable is correct:

root@raspberrypi:/home/rocketchat# cat /etc/systemd/system/rocket.chat.service
[Unit]
Description=Rocket.Chat Server
Wants=mongod.service
After=network.target mongod.service
[Service]
Type=simple
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=RocketChat
WorkingDirectory=/home/rocketchat/Rocket.Chat
ExecStart=/usr/share/meteor/dev_bundle/bin/node main.js
Environment=ROOT_URL=http://192.168.2.2:3004/ PORT=3004
Environment=MONGO_URL=mongodb://localhost:27017/rocketchat
User=rocketchat
Restart=always
[Install]
WantedBy=multi-user.target

However, the systemd logs show that the site URL is not the correct one:

root@raspberrypi:/home/rocketchat# systemctl status -l -n 30 rocket.chat
● rocket.chat.service - Rocket.Chat Server
   Loaded: loaded (/etc/systemd/system/rocket.chat.service; enabled)
   Active: active (running) since Mon 2016-07-18 10:57:59 CEST; 1min 55s ago
 Main PID: 1651 (node)
   CGroup: /system.slice/rocket.chat.service
           └─1651 /usr/share/meteor/dev_bundle/bin/node main.js

Jul 18 10:57:59 raspberrypi systemd[1]: Started Rocket.Chat Server.
Jul 18 10:58:34 raspberrypi RocketChat[1651]: Updating process.env.MAIL_URL
Jul 18 10:58:42 raspberrypi RocketChat[1651]: ufs: store created at
Jul 18 10:59:00 raspberrypi RocketChat[1651]: ufs: store created at
Jul 18 10:59:25 raspberrypi RocketChat[1651]: {"line":"114","file":"migrations.js","message":"Migrations: Not migrating, already at version 54","time":{"$date":1468832365627},"level":"info"}
Jul 18 10:59:36 raspberrypi RocketChat[1651]: Updating process.env.MAIL_URL
Jul 18 10:59:46 raspberrypi RocketChat[1651]: Using GridFS for Avatar storage
Jul 18 10:59:46 raspberrypi RocketChat[1651]: ➔ System ➔ startup
Jul 18 10:59:46 raspberrypi RocketChat[1651]: ➔ +---------------------------------------------+
Jul 18 10:59:46 raspberrypi RocketChat[1651]: ➔ |                SERVER RUNNING               |
Jul 18 10:59:46 raspberrypi RocketChat[1651]: ➔ +---------------------------------------------+
Jul 18 10:59:46 raspberrypi RocketChat[1651]: ➔ |                                             |
Jul 18 10:59:46 raspberrypi RocketChat[1651]: ➔ |       Version: 0.34.0                       |
Jul 18 10:59:46 raspberrypi RocketChat[1651]: ➔ |  Process Port: 3004                         |
Jul 18 10:59:46 raspberrypi RocketChat[1651]: ➔ |      Site URL: http://192.168.178.49:3004/  |
Jul 18 10:59:46 raspberrypi RocketChat[1651]: ➔ |                                             |
Jul 18 10:59:46 raspberrypi RocketChat[1651]: ➔ +---------------------------------------------+

Is there a config file defining the site URL? I could not find it.

GorgiAstro commented 7 years ago

OK my bad, when connecting to the web interface, I get a warning that suggests me to change the site URL... And it is possible to change it in the web interface settings.

j8r commented 7 years ago

@GorgiAstro It appears like you are using my script :) You can change Rocket.Chat environement variables like ROOT_URL in its systemd service in /etc/systemd/system/rocket.chat.service

GorgiAstro commented 7 years ago

Yes, but my question was if the site URL is defined by the environment variable ROOT_URL. Because the site URL when Rocket.Chat started (192.168.178.49) was different than the one (192.168.2.2) I had defined in the systemd service file. Now I fixed the site URL from the web interface, but maybe there is an issue in the Rocket.Chat startup process :)

j8r commented 7 years ago

After modifying it have you run systemctl daemon-reload and then systemctl restart rocket.chat?

sekrett commented 6 years ago

@GorgiAstro I had a similar problem and solved it by dropping mongo database. It appears that ROOT_URL is read and stored to mongo on first launch. So if you change it later it will be ignored.

fzamperin commented 6 years ago

@sekrett I'm having the same problem I miss-clicked the option and then my reverse proxy broke and I can't delete the whole database. Do you know which collection has the settings? Or how can I achieve your behavior?

sekrett commented 6 years ago

@fzamperin no, I don't know. I dropped entire database.

michaelgotchosen commented 6 years ago

I have been looking to change this setting for a while. I finally took the time to find it. I'm going to place it here in hopes that it will help someone else...

rocketchat->rocketchat_settings->Site_Url->value

breakdown for clarity rocketchat - db rocketchat_settings - collection Site_Url - Key value - field

Sing-Li commented 4 years ago

Excellent and thank you @michaelgotchosen

Please write a short wiki page for us if possible with the above information.

HudsonProdigy commented 4 years ago

For anyone who needed a little more clarification on @michaelgotchosen helpful post. You need to modify field in mongo db instance. open mongo shell -> use rocketchat -> db.rocketchat_settings.update({"_id" : "Site_Url"},{$set:{value:"NEW_URL"}})

Lucioric2000 commented 4 years ago

Thanks. You saved me hours.

jj-uk commented 3 years ago

Does "packageValue" also need changing?

db.rocketchat_settings.update({"_id" : "Site_Url"},{$set:{packageValue:"NEW_URL"}})