Closed FloydianSound closed 9 months ago
I dont think this will work as you need discord open to so that you can have access to the discord-ipc
thanks for you answer!
would a silent instance to push the right calls would work ? like maybe having a browser session running in the background process, or something akin to that. or maybe a plex integration ?
i'd really like to have this installed server-side and have all my webhooks and stuff be centralized this way, unless you have another idea in mind that could do something similar ?
Wow I'm in the same boat, didn't think anyone else would ask about this. Currently, I have the script running at startup on my host system running windows but I would love to be able to run this containerized on my synology so I don't ever have to think about it. oh well.
You'll have to run Discord on the NAS, and this can be done in a container as well.
~~Try this:
Run kasmweb/discord with /tmp/discord
from the host mounted into the container at /tmp
. Access it through your browser as per their instructions and sign into Discord.
Run ghcr.io/phin05/discord-rich-presence-plex with /tmp/discord
from the host mounted into the container at /run/app
.~~
Edit for future visitors: Take a look at the kasmweb/discord example from the README for a better solution.
when you say:
Run kasmweb/discord with /tmp/discord from the host mounted into the container at /tmp.
Is it possible to mount the temp folder created by discord (that's probably located in appdata) on my host windows machine into the container at /tmp? So I would have to create a network mount of the discord temp folder on my machine on the synology and mount that in the discord container?
No, /tmp/discord
would be a new temporary folder on your NAS meant for use by both kasmweb/discord and discord-rich-presence-plex. That needs to be mounted into the kasmweb/discord container as /tmp
because that's where Discord running inside that container would store its inter-process communication Unix socket file. The discord-rich-presence-plex container needs to access this file and looks for it in /run/app
if such folder exists, so the same /tmp/discord
host folder needs to be mounted in as /run/app
.
On Windows, a different mechanism is used to communicate and this is not compatible with Linux, so it's not possible to share the communication pipe of your Windows Discord instance.
I see. I will attempt this. That makes a lot more sense and is what I originally tried but I think I had trouble running discord containerized so I gave up.
Thank you for creating this by the way. I really appreciate and prefer it over the alternatives that provide a similar solution with the exception of posters.
this is the same issue I ran into last time. the kasmweb discord container fails to run and throws all these errors regarding being incapable of accessing the system D-Bus. Below I have provided an excerpt of the end of the log when attempting to launch the discord container for the first time but I can provide more if you feel you can help get this working. I have looked into this extensively and the problem with the potential solution is that I can't troubleshoot the D-Bus service because systemd doesn't exist on synology. I am using kasmweb/discord:1.14.0-rolling and DSM 7.2.1-69057 Update 3 I will try the release that isn't marked rolling just in case that is the issue but I think I tried all this last time and it still went unresolved.
xdg-open
mainScreen.UpdaterEvents: UPDATER_HISTORY_QUERY_AND_TRUNCATE
** (xiccd:432): CRITICAL **: 08:09:18.476: Failed to connect to colord: Could not connect: No such file or directory
(nm-applet:425): nm-applet-WARNING **: 08:09:18.560: Error connecting to system D-Bus: Could not connect: No such file or directory
(nm-applet:425): nm-applet-WARNING **: 08:09:18.561: Could not connect: No such file or directory
(nm-applet:425): libnm-CRITICAL **: 08:09:18.562: ((libnm/nm-client.c:3905)): assertion '<dropped>' failed
(nm-applet:425): libnm-CRITICAL **: 08:09:18.564: ((libnm/nm-client.c:3859)): assertion '<dropped>' failed
(nm-applet:425): libnm-CRITICAL **: 08:09:18.564: ((libnm/nm-client.c:3937)): assertion '<dropped>' failed
(nm-applet:425): libnm-CRITICAL **: 08:09:18.564: ((libnm/nm-client.c:3986)): assertion '<dropped>' failed
(nm-applet:425): libnm-CRITICAL **: 08:09:18.564: ((libnm/nm-client.c:4026)): assertion '<dropped>' failed
(nm-applet:425): libnm-CRITICAL **: 08:09:18.564: ((libnm/nm-client.c:4042)): assertion '<dropped>' failed
(nm-applet:425): libnm-CRITICAL **: 08:09:18.564: ((libnm/nm-client.c:4080)): assertion '<dropped>' failed
(nm-applet:425): libnm-CRITICAL **: 08:09:18.564: ((libnm/nm-client.c:4598)): assertion '<dropped>' failed
(nm-applet:425): libnm-CRITICAL **: 08:09:18.564: ((libnm/nm-client.c:4598)): assertion '<dropped>' failed
system-config-printer-applet: failed to connect to system D-Bus
Is the container stopping after that? If not, did you try accessing it regardless of the error?
No it doesn't stop. But I cannot connect to it. I will send the logs when trying to connect in a second.
2024-01-31 08:57:53,140 [DEBUG] websocket 0: non-SSL connection disallowed
2024-01-31 08:57:53,140 [DEBUG] websocket 0: No connection after handshake
2024-01-31 08:57:53,140 [DEBUG] websocket 0: handler exit
2024-01-31 08:57:53,142 [INFO] websocket 1: got client connection from 172.17.0.1
2024-01-31 08:57:53,143 [DEBUG] websocket 1: non-SSL connection disallowed
2024-01-31 08:57:53,143 [DEBUG] websocket 1: No connection after handshake
2024-01-31 08:57:53,143 [DEBUG] websocket 1: handler exit
2024-01-31 08:57:53,144 [INFO] websocket 2: got client connection from 172.17.0.1
2024-01-31 08:57:53,145 [DEBUG] websocket 2: non-SSL connection disallowed
2024-01-31 08:57:53,145 [DEBUG] websocket 2: No connection after handshake
2024-01-31 08:57:53,145 [DEBUG] websocket 2: handler exit
2024-01-31 08:57:53,146 [INFO] websocket 3: got client connection from 172.17.0.1
2024-01-31 08:57:53,147 [DEBUG] websocket 3: non-SSL connection disallowed
2024-01-31 08:57:53,147 [DEBUG] websocket 3: No connection after handshake
2024-01-31 08:57:53,147 [DEBUG] websocket 3: handler exit
2024-01-31 08:57:53,153 [INFO] websocket 4: got client connection from 172.17.0.1
2024-01-31 08:57:53,154 [DEBUG] websocket 4: non-SSL connection disallowed
2024-01-31 08:57:53,154 [DEBUG] websocket 4: No connection after handshake
2024-01-31 08:57:53,154 [DEBUG] websocket 4: handler exit
2024-01-31 08:57:53,156 [INFO] websocket 5: got client connection from 172.17.0.1
2024-01-31 08:57:53,157 [DEBUG] websocket 5: non-SSL connection disallowed
2024-01-31 08:57:53,157 [DEBUG] websocket 5: No connection after handshake
2024-01-31 08:57:53,157 [DEBUG] websocket 5: handler exit
2024-01-31 08:57:53,158 [INFO] websocket 6: got client connection from 172.17.0.1
2024-01-31 08:57:53,159 [DEBUG] websocket 6: non-SSL connection disallowed
2024-01-31 08:57:53,159 [DEBUG] websocket 6: No connection after handshake
2024-01-31 08:57:53,159 [DEBUG] websocket 6: handler exit
2024-01-31 08:57:53,161 [INFO] websocket 7: got client connection from 172.17.0.1
2024-01-31 08:57:53,161 [DEBUG] websocket 7: non-SSL connection disallowed
2024-01-31 08:57:53,161 [DEBUG] websocket 7: No connection after handshake
2024-01-31 08:57:53,161 [DEBUG] websocket 7: handler exit
2024-01-31 08:57:53,162 [INFO] websocket 8: got client connection from 172.17.0.1
2024-01-31 08:57:53,164 [DEBUG] websocket 8: non-SSL connection disallowed
2024-01-31 08:57:53,164 [DEBUG] websocket 8: No connection after handshake
2024-01-31 08:57:53,164 [DEBUG] websocket 8: handler exit
2024-01-31 08:57:53,166 [INFO] websocket 9: got client connection from 172.17.0.1
2024-01-31 08:57:53,167 [DEBUG] websocket 9: non-SSL connection disallowed
2024-01-31 08:57:53,167 [DEBUG] websocket 9: No connection after handshake
2024-01-31 08:57:53,167 [DEBUG] websocket 9: handler exit
kasmweb/discord doesn't allow non-SSL HTTP connections. Change your URL's scheme to https
and ignore the SSL errors shown by your browser.
As mentioned in their instructions, "https://IP_OF_SERVER:6901"
No way I have that much brain damage. Wow. Thank you. I will let you know if I have any problems from here on out but I doubt it. The reason why I was using the link containing "http" instead of "https" is because portainer automatically directs you to the insecure version when you click the hyperlinked port in the list of running containers. I never thought to try "https" because I fixated on that D-Bus error. Thank you and I feel so stupid.
yeah I never saw that in their instructions because of how much tunnel vision I got thinking the D-Bus error was the culprit.
Haha, it's okay. Let me know if you manage to get it to work.
@N72826 I ran into errors when I was testing this because the permissions on /tmp/discord
were restrictive for non-root users due to it being automatically created by the Docker daemon which runs as root. Mounting that into the container as /tmp
is problematic because /tmp
needs to be accessible by every user. Not sure how you got around this but I had to manually set the permissions on /tmp/discord
to 777 to get kasmweb/discord to run.
I also realised that /tmp
is not persistent, so if the system rebooted, the same issue would occur since /tmp/discord
wouldn't exist and the Docker daemon would auto-create it with restrictive permissions. To avoid this, I would suggest creating a different persistent host directory with permissions set to 777, for example /var/discord-tmp
, and using that instead of /tmp/discord
.
well I have a synology share dedicated to persistent directories used by docker. A separate docker group is created upon the installation of docker and I gave that group full perms to the docker share I use for those persistent directories. I think that is why I didn't run into any issues originally. For example, I have "kasmweb-discord/tmp" bound to "/tmp" within the discord container and that worked fine.
Now after setting up the compose stack in portainer, I can access the VNC dashboard but something is preventing discord from being installed into the container. I can visit the address of kasmweb-discord and see the dashboard, but discord clearly hasn't been installed. I'm checking the logs real quick to see what the issue is. I haven't even gotten to testing your container yet but it seems to be running fine in the stack.
/dockerstartup/custom_startup.sh: line 50: 32168 Trace/breakpoint trap (core dumped) $START_COMMAND $ARGS $URL
filter is not configured
Discord 0.0.42
this is the error I'm getting and this is what I see when I access the address that the discord container is hosted at
here's my compose stack:
version: '1.0'
services:
kasm-discord:
container_name: kasmweb-discord
image: kasmweb/discord:1.14.0-rolling
restart: unless-stopped
ports:
- 6901:6901
shm_size: '512m'
environment:
- VNC_PW=REDACTED
volumes:
- /REDACTED/REDACTED/kasmweb-discord/tmp:/tmp
discord-rich-presence:
container_name: discord-RPC
image: ghcr.io/phin05/discord-rich-presence-plex
restart: unless-stopped
volumes:
- /REDACTED/REDACTED/kasmweb-discord/tmp:/run/app
- /REDACTED/docker/discord-RPC:/app/data
Not sure how this is possible, was able to get the discord container running using the provided docker run command and executing it manually. All I did was adapt the run command into a compose file so that I don't have to run it manually.
Can you verify that the permissions on kasmweb-discord/tmp
is set to 777 (or 1777)? Run stat /REDACTED/REDACTED/kasmweb-discord/tmp
and check the "Access" part.
oh shit well its not. but thats confusing because I was successful in running it before.
its chown right?
chown 777 /REDACTED/REDACTED/kasmweb-discord/tmp
should do the job.
Oops, I mean chmod
I knew it was one of them lol
so now I'm confused. one sec let me try to run the container again manually and see why it's failing in portainer.
I'm not sure what's wrong. kasmweb/discord works for me with the same compose stack as yours.
However, while testing, I noticed that a couple more changes are required to make this work properly:
Firstly, setting XDG_RUNTIME_DIR
for the kasmweb/discord container to /run/user/1000
makes Discord use that directory instead of /tmp
to store its IPC Unix socket file. With this, you can avoid mounting into /tmp
and filling up the mounted host directory with other temporary junk.
Secondly, you need to set the DRPP_CONTAINER_DEMOTION_UID_GID
environment variable for the discord-rich-presence-plex container to 1000. By default, my script demotes itself from root to user ID 10000, which prevents it from accessing the IPC Unix socket file created by Discord in kasmweb/discord which is running as user ID 1000. So, this environment variable needs to be overridden to make my script demote itself to user ID 1000 instead. I would suggest testing it first without setting this environment variable as it seems like behaviour related to Unix socket file permissions might differ across different Linux distributions, so it might work for you without this.
My working compose stack (tested on Arch Linux x86_64 6.7.2-arch1-1) is as under:
services:
kasmweb-discord:
container_name: kasmweb-discord
image: kasmweb/discord:1.14.0-rolling
restart: unless-stopped
ports:
- 6901:6901
shm_size: 512m
environment:
VNC_PW: password
XDG_RUNTIME_DIR: /run/user/1000
volumes:
- /var/discord-tmp:/run/user/1000
drpp:
container_name: drpp
image: ghcr.io/phin05/discord-rich-presence-plex:latest
restart: unless-stopped
environment:
DRPP_CONTAINER_DEMOTION_UID_GID: 1000
volumes:
- /var/discord-tmp:/run/app:ro
- ./drpp:/app/data
dude! perfect timing. I made major progress after fucking around with it. I knew something was off when I could run the discord container manually through ssh but when trying to use portainer, it kept failing. Remember when I said this:
well I have a synology share dedicated to persistent directories used by docker. A separate docker group is created upon the installation of docker and I gave that group full perms to the docker share I use for those persistent directories.
Well guess what, I took a shot in the dark and checked the docker group permissions through the DSM UI and... the docker group never had perms. 😳
I just gave it perms and now I am able to run the discord container in portainer and access it without problems. I was just about to get back to you about the socket permission issue so thank you. I will check out your fix, I believe it will work.
Also I'm going to take your other suggestion about not using tmp because you are right, there are so many junk files.
I left for a bit but everything is working smoothly now and I couldn't be happier. Thanks man, I really appreciate your help. my discord is n72826 if you want to chat sometime.
No problem, glad it works.
I've pushed a new version (v2.4.4) to address the permission issue. The DRPP_CONTAINER_DEMOTION_UID_GID
environment variable is no longer required. Take a look at the kasmweb/discord example from the README for an updated compose stack, which also includes a custom entry point for the kasmweb/discord container to fix ownership of the mounted-in runtime directory (changes owner to 1000, Discord runs as 1000, this script will infer from the mounted-in directory and also run as 1000, so there should be no issues).
@FloydianSound The kasmweb/discord example added to the README is proven to work so I'll be closing this issue. Try it out and comment here if you need any assistance.
@FloydianSound The kasmweb/discord example added to the README is proven to work so I'll be closing this issue. Try it out and comment here if you need any assistance.
why thanks so much! i've had my hands busy this last month with work and i didn't follow up, here i am now !
this is great, i will go through the thread to read about it, and will get back to you to confirm it works on my end as well !
@N72826 glad we had this same question and need ! 🦾 @phin05 thanks for taking the time with all this 😸
Alright, so i was able to create a docker-compose file through the UI, and have both container running. i am however not seeing change in discord, i might be missing something obvious. you mentionned mounting a share for DRPP to fetch files from KASM, but i have not figured what you mean and which folder would it be. here's some screenshots.
here is my hierarchy DRPP has only a config.yaml file inside, Kasmcord has 4 folders and a ICEauthority file.
and the YAML from the README (i had to make folders manually, otherwise it throws an error when trying to launch containers)
services:
kasmcord:
container_name: kasmcord
image: kasmweb/discord:1.14.0
restart: unless-stopped
ports:
- 6901:6901
shm_size: 512m
environment:
VNC_PW: password
XDG_RUNTIME_DIR: /run/user/1000
volumes:
- ./kasmcord:/run/user/1000
user: "0"
entrypoint: sh -c "chmod 700 /run/user/1000 && chown -R kasm-user:kasm-user /run/user/1000 && su kasm-user -c '/dockerstartup/kasm_default_profile.sh /dockerstartup/vnc_startup.sh /dockerstartup/kasm_startup.sh'"
drpp:
container_name: drpp
image: ghcr.io/phin05/discord-rich-presence-plex:latest
restart: unless-stopped
volumes:
- ./drpp:/app/data
- ./kasmcord:/run/app:ro
depends_on:
- kasmcord
you mentionned mounting a share for DRPP to fetch files from KASM, but i have not figured what you mean and which folder would it be
That's already done through the Compose file. The kasmcord
folder is mounted into both the containers at the appropriate places.
i had to make folders manually, otherwise it throws an error when trying to launch containers
Docker is supposed to create the folders automatically so I'm not sure why that is.
- Have you signed into Discord on the Kasm container?
yes ! that worked like a charm.
- Check the logs of the DRPP container. What do you see?
it mentionned logging into plex in a browser, which i did, then restarted the container. it asks me again. i suspect a permission issue as usual. IIRC docker has a UID of 1000 and GID of 1000 ?
you mentionned mounting a share for DRPP to fetch files from KASM, but i have not figured what you mean and which folder would it be
That's already done through the Compose file. The
kasmcord
folder is mounted into both the containers at the appropriate places.i had to make folders manually, otherwise it throws an error when trying to launch containers
Docker is supposed to create the folders automatically so I'm not sure why that is.
it seems to happen with every docker-compose.yaml file i create through the UI. doesn't create folders by itself, but it does fetch the image... also all the folders were created by my user (floydiansound), that includes both kasmcord-drpp and the kasmcord and drpp folders. the contents of those, are created from the compose-yaml
there have been times where i need to put git releases files in there manually after folder creation. could that be the step i forgot, or is everything included in your images ?
here is a screenshot of the error
it mentionned logging into plex in a browser, which i did, then restarted the container. it asks me again.
Are you sure your sign-in was successful? You should see a "Authentication successful" message in the DRPP container logs. I only see a "Authentication timed out" message in the screenshot.
i suspect a permission issue as usual. IIRC docker has a UID of 1000 and GID of 1000 ?
There should be no permission issues since the proper permissions are set by the Kasm entrypoint in the Compose file and DRPP will adjust accordingly.
there have been times where i need to put git releases files in there manually after folder creation. could that be the step i forgot, or is everything included in your images ?
That's not necessary. The Docker image has everything.
here is an updated SS
You missed this (other info / env var section in README), so the Plex server name is set to ServerName
by default. Change ServerName
in config.yaml to your Plex server's name and restart the container.
You missed this (other info / env var section in README), so the Plex server name is set to
ServerName
by default. Edit the config.yaml file and changeServerName
to your Plex server's name.
right... worst is i have read that part. Container Manager UI doesn't allow you to setup ENV in advance other than inside the compose.yaml ... you would have to edit the container directly to add this variable, which needs to be built using the container manager. a real catch-22 ?
tried renaming the server to my server name, but everytime i save the file, it reverts back.
I edited your comment to redact your Plex token which was exposed in your screenshot.
Container Manager UI doesn't allow you to setup ENV in advance other than inside the compose.yaml
Setting it in the Compose file is the way, that's how it's done for all Docker containers while using Docker Compose. You don't need to edit the container or its image or the host environment variables.
Since you've already signed in now, you don't need to set it since it doesn't matter (unless you delete the config file). You just need to edit the config file to change ServerName
.
tried renaming the server to my server name, but everytime i save the file, it reverts back
I'm not sure what's going on there. It must be some issue with the container manager?
alright, to fix this broken thing....
i added the environment variables to the container as such: (last line)
then i have reset the container using the top right menu.
i deleted the local file config.yaml inside the DRPP folder
relaunched the whole project+containers
logged into plex web
logged into https://my.local.ip.address:6901 and into discord itself.
no errors
and now it works !
@phin05 thanks a lot for your assistance. i know it's outside "your" project, but i really appreciate your help and you accomodating us in this !
i can now be anywhere in the world and this will work without a PC on, ever ! i hope this whole thread will be useful for the next crazy people who wants to do the same. i can also now uninstall that agent on windows that did great, but was the last thing i wanted to get rid and have things 100% hosted on the NAS itself.
as an added thing, you mentionned heavy overhead for kasmcord, and it might prove useful for others
there is a feature inside container manager to set resources limits. i set that to low and 4096 as shown here seems to have reduced the media usage from 60% to 30%
you can see a comparison between the spikes (turned it on and off twice....)
No problem, glad it works!
Also, I suggest revoking the exposed Plex token by deleting the PlexAPI device from authorised devices in Plex account settings since the screenshot containing the token is still cached on GitHub servers.
If you do that, you would also have to clear the users list in the config file (change to users: []
, or delete the file if you're still unable to edit it) and restart the container to make it prompt for authentication again.
i'm assuming you mean the DRPP one ?
Yeah that's the one, wasn't sure what it would be named for you so I mentioned "PlexAPI" which is on the 3rd line.
done, done and done !
the file was still not editable, suspecting permissions as usual. deleting it did the trick.
works fine now, thanks for reminding me 😸
alright, interesting....
it worked fine for a while, then it simply stopped showing all of a sudden. then showed again for a couple of seconds, then off again.
no biggie, i restart the whole project. then tried swapping to another song, showed for a few seconds, stopped again. i do notice there is a 30 second "delta" between my song counter and the display in discord. maybe something is up ?
here's a screenshot of the log, i can provide an HTML file if you need to read more
Is this happening consistently? It appears to be a connection issue. The script tried to fetch an item from the Plex server, but the Plex server dropped the connection before this fetch request was completed.
monitoring, left it running, watched some other things, then came back. it now has proper timestamp shown, down to a second or two (good enough for me :P ) then if i leave the preview going, it drops for a few seconds, then come back again, yet with a minute late timestamp
not sure what to make out of all this tbh. can't think of why this is.
do note i use PlexAMP for this currently, but since it's all server side, it shouldn't really be an issue ?
then if i leave the preview going, it drops for a few seconds, then come back again, yet with a minute late timestamp
Are there any errors in logs when this happens? And does the timestamp correct itself after a few seconds? Discord doesn't update the rich presence immediately sometimes, and the script delays it a bit as well if the media being played hasn't changed, to prevent spamming requests to Discord.
do note i use PlexAMP for this currently, but since it's all server side, it shouldn't really be an issue ?
Yeah, that should be fine.
ss explained in the Title....
is it possible to run this in a Docker Container on a Synology Nas ?
my specific setup : Synology DS224+ (DSM7.2) Plex Media Server Package from official synology repo running Tautulli and other plug-ins as Docker Containers (everything works find so far...)
i would like to run this script as a resident agent as well, so it would still update whatever app/media/location i access (Plex/Plex HTPC/PlexAMP on Windows and Android)
will i need to run a discord instance on the same or a different connected container ? i don't have much experience with dockers, i'm still learning :)
Thanks !