MusicBot icon indicating copy to clipboard operation
MusicBot copied to clipboard

[Feature Request] Allow users to set a custom 'serversettings.json' path

Open DyonR opened this issue 4 years ago • 5 comments

Is your feature request related to a problem? Please describe. At this moment, I believe there is no way to set a custom path for the serversettings.json For the config.txt this is possible by adding -Dconfig to the command line, but for serversettings.json this is not possible.

Describe the solution you'd like I would like to see a new command line argument called -Dserversettings which can point to a location where the serversettings.json should be saved, similar to -Dconfig which points to the config.txt

Describe the basic flow/steps of using this feature How this feature would be used:

  1. Users will obtain the ability to set a custom serversettings.json path using -Dserversettings

Additional context none

Please check the following links to confirm that your feature has not already been requested: https://github.com/jagrosh/MusicBot/labels/enhancement https://github.com/jagrosh/MusicBot/wiki/Things-That-Won%27t-Be-Added

DyonR avatar Sep 13 '21 14:09 DyonR

As a workaround, I think you should be able to change your current directory using cd. since it tries using the serversettings.json from your current directory

MichailiK avatar Sep 14 '21 07:09 MichailiK

As a workaround, I think you should be able to change your current directory using cd. since it tries using the serversettings.json from your current directory

Thanks, looking into it; I start a JMusicBot instance with init (start-stop-daemon) automatically on a machine, but by default it runs from /, I didn't notice this has a --chdir argument, so I've added that now and that works.
So that works, which is great! But, the more flexability you have from the command line the better in my opinion

DyonR avatar Sep 14 '21 14:09 DyonR

Alternatively, if you're on Linux, you could create a symbolic link.

RdJNL avatar Sep 17 '21 14:09 RdJNL

For anyone running a system with systemd, you can work around this by setting the WorkingDirectory attribute under [Service] in your .service file.

As an example, I use /var/opt/musicbot as my working directory, and can change the service to this as follows: WorkingDirectory=/var/opt/musicbot

Tyrasuki avatar Jun 05 '22 16:06 Tyrasuki

One reason you might want this is if you are deploying the bot via Kubernetes, and you wish for the serverSettings.json to be located in a persistent volume. Creating a symbolic link when building the Docker image works well. Something like:

Dockerfile:

ARG SERVER_SETTINGS_PATH="/path/to/some/future/volume"
# ...snip...
RUN mkdir -p $SERVER_SETTINGS_PATH && \
    touch $SERVER_SETTINGS_PATH/serversettings.json && \
    ln -s $SERVER_SETTINGS_PATH/serversettings.json serversettings.json 

deployment.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: jmusicbot
  labels:
    app: jmusicbot
spec:
  replicas: 1
  selector:
    matchLabels:
      app: jmusicbot
  template:
    metadata:
      labels:
        app: jmusicbot
    spec:
      containers:
        - name: jmusicbot
          image: your_image_here
          volumeMounts:
            - name: serversettings-dir
              mountPath: /path/to/some/future/volume
      volumes:
        - name: serversettings-dir
          persistentVolumeClaim:
            claimName: my-persistent-volume-claim

gurchik avatar Jul 10 '22 21:07 gurchik