Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XBS-API container continually restarting and will not remain connected to docker stack network. #15

Open
xthursdayx opened this issue Jul 21, 2021 · 11 comments

Comments

@xthursdayx
Copy link

I didn't want to highjack this issue: #13 but I too am trying to run the xbrowsersync api-docker stack without caddy, so that I can then use NGINX to reverse proxy the container, since I already use it for other containers, but am running into some issues.

I've tried creating and starting the stack with the docker-compose.yml (only modified to change the mounted port) you posted in issue #13 using docker-compose up -d and have also tried creating the stack via Portainer using the docker-compose as a template. I've also tried just creating the api-docker container manually with a docker run command including all of the necessary variables and a separately created MongoDB.

For some reason in each case the MongoDB container and xbs-api container are created and the db container seems to function normally, but the xbs-api container continually restarts and won't stay connected to the xbs docker network that is created. I've tried changing the healthcheck interval, timeout length, retries, and start period, and also tried removing the healthcheck entirely, just to see, but it found the same issue, though I couldn't tell if the container was restarting or just refusing to connect to the xbrowsersync docker network and mount the 8080 port.

I am unable to access the internal container logs because the container is continually restarting and there isn't anything in the external logs for the xbs-api container. The most information I could find was by inspecting the container in Portainer, which listed this information about the container:

{
    "AppArmorProfile": "",
    "Args": [
        "node",
        "dist/api.js"
    ],
    "Config": {
        "AttachStderr": false,
        "AttachStdin": false,
        "AttachStdout": false,
        "Cmd": [
            "node",
            "dist/api.js"
        ],
        "Domainname": "",
        "Entrypoint": [
            "docker-entrypoint.sh"
        ],
        "Env": [
            "XBROWSERSYNC_DB_PWD=$$$$$$$$$$$$$$$$",
            "XBROWSERSYNC_DB_USER=xbsdb",
            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
            "NODE_VERSION=14.16.0",
            "YARN_VERSION=1.22.5",
            "XBROWSERSYNC_API_VERSION=1.1.13"
        ],
        "ExposedPorts": {
            "8080/tcp": {}
        },
        "Healthcheck": {
            "Interval": 60000000000,
            "Retries": 5,
            "StartPeriod": 60000000000,
            "Test": [
                "CMD",
                "node",
                "/usr/src/api/healthcheck.js"
            ],
            "Timeout": 15000000000
        },
        "Hostname": "2fd2ed50a788",
        "Image": "xbrowsersync/api:1.1.13",
        "Labels": {
            "com.docker.compose.config-hash": "1470d7e395c3ac183006d6d8f0fe41daa500391ff16895c70eba8608a139c269",
            "com.docker.compose.container-number": "1",
            "com.docker.compose.oneoff": "False",
            "com.docker.compose.project": "xbrowsersync",
            "com.docker.compose.project.config_files": "docker-compose.yml",
            "com.docker.compose.project.working_dir": "/mnt/cache/appdata/xbrowsersync",
            "com.docker.compose.service": "api",
            "com.docker.compose.version": "1.29.2"
        },
        "OnBuild": null,
        "OpenStdin": false,
        "StdinOnce": false,
        "Tty": false,
        "User": "",
        "Volumes": {
            "/usr/src/api/config/settings.json": {},
            "/usr/src/api/healthcheck.js": {}
        },
        "WorkingDir": "/usr/src/api"
    },
    "Created": "2021-07-21T19:09:43.778416987Z",
    "Driver": "btrfs",
    "ExecIDs": null,
    "GraphDriver": {
        "Data": null,
        "Name": "btrfs"
    },
    "HostConfig": {
        "AutoRemove": false,
        "Binds": [
            "/mnt/cache/appdata/xbrowsersync/settings.json:/usr/src/api/config/settings.json:rw",
            "/mnt/cache/appdata/xbrowsersync/healthcheck.js:/usr/src/api/healthcheck.js:rw"
        ],
        "BlkioDeviceReadBps": null,
        "BlkioDeviceReadIOps": null,
        "BlkioDeviceWriteBps": null,
        "BlkioDeviceWriteIOps": null,
        "BlkioWeight": 0,
        "BlkioWeightDevice": null,
        "CapAdd": null,
        "CapDrop": null,
        "Cgroup": "",
        "CgroupParent": "",
        "CgroupnsMode": "host",
        "ConsoleSize": [
            0,
            0
        ],
        "ContainerIDFile": "",
        "CpuCount": 0,
        "CpuPercent": 0,
        "CpuPeriod": 0,
        "CpuQuota": 0,
        "CpuRealtimePeriod": 0,
        "CpuRealtimeRuntime": 0,
        "CpuShares": 0,
        "CpusetCpus": "",
        "CpusetMems": "",
        "DeviceCgroupRules": null,
        "DeviceRequests": null,
        "Devices": null,
        "Dns": null,
        "DnsOptions": null,
        "DnsSearch": null,
        "ExtraHosts": null,
        "GroupAdd": null,
        "IOMaximumBandwidth": 0,
        "IOMaximumIOps": 0,
        "IpcMode": "private",
        "Isolation": "",
        "KernelMemory": 0,
        "KernelMemoryTCP": 0,
        "Links": null,
        "LogConfig": {
            "Config": {
                "max-file": "1",
                "max-size": "500m"
            },
            "Type": "json-file"
        },
        "MaskedPaths": [
            "/proc/asound",
            "/proc/acpi",
            "/proc/kcore",
            "/proc/keys",
            "/proc/latency_stats",
            "/proc/timer_list",
            "/proc/timer_stats",
            "/proc/sched_debug",
            "/proc/scsi",
            "/sys/firmware"
        ],
        "Memory": 0,
        "MemoryReservation": 0,
        "MemorySwap": 0,
        "MemorySwappiness": null,
        "NanoCpus": 0,
        "NetworkMode": "xbrowsersync_default",
        "OomKillDisable": false,
        "OomScoreAdj": 0,
        "PidMode": "",
        "PidsLimit": null,
        "PortBindings": {
            "8080/tcp": [
                {
                    "HostIp": "",
                    "HostPort": "9009"
                }
            ]
        },
        "Privileged": false,
        "PublishAllPorts": false,
        "ReadonlyPaths": [
            "/proc/bus",
            "/proc/fs",
            "/proc/irq",
            "/proc/sys",
            "/proc/sysrq-trigger"
        ],
        "ReadonlyRootfs": false,
        "RestartPolicy": {
            "MaximumRetryCount": 0,
            "Name": "unless-stopped"
        },
        "Runtime": "runc",
        "SecurityOpt": null,
        "ShmSize": 67108864,
        "UTSMode": "",
        "Ulimits": null,
        "UsernsMode": "",
        "VolumeDriver": "",
        "VolumesFrom": []
    },
    "HostnamePath": "/var/lib/docker/containers/2fd2ed50a788cb1cd7798d04fdec5597987933f65556d443ea65146e9292187c/hostname",
    "HostsPath": "/var/lib/docker/containers/2fd2ed50a788cb1cd7798d04fdec5597987933f65556d443ea65146e9292187c/hosts",
    "Id": "2fd2ed50a788cb1cd7798d04fdec5597987933f65556d443ea65146e9292187c",
    "Image": "sha256:91a6004ca7ffbf988c9c1bd96ad4c5c3f379a64930cd770c2be25b78897ce6d1",
    "LogPath": "/var/lib/docker/containers/2fd2ed50a788cb1cd7798d04fdec5597987933f65556d443ea65146e9292187c/2fd2ed50a788cb1cd7798d04fdec5597987933f65556d443ea65146e9292187c-json.log",
    "MountLabel": "",
    "Mounts": [
        {
            "Destination": "/usr/src/api/config/settings.json",
            "Mode": "rw",
            "Propagation": "rprivate",
            "RW": true,
            "Source": "/mnt/cache/appdata/xbrowsersync/settings.json",
            "Type": "bind"
        },
        {
            "Destination": "/usr/src/api/healthcheck.js",
            "Mode": "rw",
            "Propagation": "rprivate",
            "RW": true,
            "Source": "/mnt/cache/appdata/xbrowsersync/healthcheck.js",
            "Type": "bind"
        }
    ],
    "Name": "/xbs-api",
    "NetworkSettings": {
        "Bridge": "",
        "EndpointID": "",
        "Gateway": "",
        "GlobalIPv6Address": "",
        "GlobalIPv6PrefixLen": 0,
        "HairpinMode": false,
        "IPAddress": "",
        "IPPrefixLen": 0,
        "IPv6Gateway": "",
        "LinkLocalIPv6Address": "",
        "LinkLocalIPv6PrefixLen": 0,
        "MacAddress": "",
        "Networks": {
            "xbrowsersync_default": {
                "Aliases": [
                    "2fd2ed50a788",
                    "api"
                ],
                "DriverOpts": null,
                "EndpointID": "",
                "Gateway": "",
                "GlobalIPv6Address": "",
                "GlobalIPv6PrefixLen": 0,
                "IPAMConfig": null,
                "IPAddress": "",
                "IPPrefixLen": 0,
                "IPv6Gateway": "",
                "Links": null,
                "MacAddress": "",
                "NetworkID": "6da5cbc7defaa405f1ca810aa6e3c352e4125f5ceb98d4e7e3cb35e7f6e91e50"
            }
        },
        "Ports": {},
        "SandboxID": "71240f69c21e65f3064fdee118d2abe192373bf01a86297e6f0d98b71fc352b1",
        "SandboxKey": "/var/run/docker/netns/71240f69c21e",
        "SecondaryIPAddresses": null,
        "SecondaryIPv6Addresses": null
    },
    "Path": "docker-entrypoint.sh",
    "Platform": "linux",
    "ProcessLabel": "",
    "ResolvConfPath": "/var/lib/docker/containers/2fd2ed50a788cb1cd7798d04fdec5597987933f65556d443ea65146e9292187c/resolv.conf",
    "RestartCount": 9,
    "State": {
        "Dead": false,
        "Error": "",
        "ExitCode": 1,
        "FinishedAt": "2021-07-21T19:20:02.315781644Z",
        "Health": {
            "FailingStreak": 0,
            "Log": [],
            "Status": "unhealthy"
        },
        "OOMKilled": false,
        "Paused": false,
        "Pid": 0,
        "Restarting": true,
        "Running": true,
        "StartedAt": "2021-07-21T19:20:01.697109363Z",
        "Status": "restarting"
    }
}

I am trying to start the container on unRAID which is an OS based on Slackware. Any advice or suggestion would bee much appreciated. Thanks!

@xthursdayx
Copy link
Author

Also, just to provide further info this is what is in my settings.json:

{
  "dailyNewSyncsLimit": 0,
  "db": {
    "host": "db"
  }
  "maxSyncs": 5242,
  "maxSyncSize": 1048576,
  "status": {
    "allowNewSyncs": true,
    "message": "Welcome to my XBrowserSync instance",
    "online": true
  },
  "throttle": {
    "maxRequests": 1000,
    "timeWindow": 300000
  }
}

@AnthonyEnr1quez
Copy link

I am also having the same issue

@Tamariniak
Copy link

I am having the same issue. While I was trying to find the syntax for settings.json, I noticed that https://github.com/xbrowsersync/api-docker doesn’t contain any settings.default,json file (as referenced in the (documentation)[https://github.com/xbrowsersync/api#3-modify-configuration-settings] (pt 4.). I tried setting server.behindProxy to true, but it didn’t help.

@a1994sc
Copy link

a1994sc commented Oct 30, 2021

I am also having issues with it constantly crashing, but in my kubernetes cluster, but not my swarm cluster... The following settings.json is my swarm config that works on v1.1.13

{
  "db": {
    "host": "db_mongodb",
    "name": "xbrowsersync",
    "username": "sxbs",
    "password": "123password",
    "authSource": "xbrowsersync"
  },
  "maxSyncs": 0,
  "maxSyncSize": 1024000000,
  "status": {
    "allowNewSyncs": false,
    "message": "Derpaholic xBrowserSync."
  },
  "server": {
    "behindProxy": true,
    "host": "xbs.derpaholic.com",
    "https": {
      "certPath": "",
      "enabled": false,
      "keyPath": ""
    },
    "port": 8080,
    "relativePath": "/"
  },
  "dailyNewSyncsLimit": 0
}

Also here is my yaml files for kub if people wanted to check those

@nero120 nero120 closed this as completed Dec 1, 2021
@nero120
Copy link
Member

nero120 commented Dec 1, 2021

I am having the same issue. While I was trying to find the syntax for settings.json, I noticed that https://github.com/xbrowsersync/api-docker doesn’t contain any settings.default,json file (as referenced in the (documentation)[https://github.com/xbrowsersync/api#3-modify-configuration-settings] (pt 4.). I tried setting server.behindProxy to true, but it didn’t help.

settings.default.json are the DEFAULT settings, you provide a settings.json to override them, like so:

https://github.com/xbrowsersync/api-docker/blob/master/settings.json

@nero120
Copy link
Member

nero120 commented Dec 1, 2021

@xthursdayx are you able to run the API on it's own (not with docker)?

@nero120 nero120 reopened this Dec 1, 2021
@a1994sc
Copy link

a1994sc commented Dec 1, 2021

I have tried to run in a debug mode but no option exists to get any out before the container restarts.

@nero120
Copy link
Member

nero120 commented Dec 1, 2021

Can you run the following command and paste the output here:

 docker-compose logs --tail 50 --follow --timestamps api

Edit: also, to prevent the container from constantly restarting, update line 33 of docker-compose.yml to restart: "no"

@mad-max-traveller
Copy link

Hello. I encountered a similar problem, but under different conditions.
I wanted to raise the service using Docker on my local network. The first step I set up everything on my work computer. I removed the reverse-proxy as I don't need it. And successfully started the xbrowsersync service on my computer. I installed the addon in my browser and set up the sync, everything works great.
The second step I decided to move the xbrowsersync service to my server on the local network. I just copied the configuration files and ran them with $ sudo docker-compose up After that I got an error:

xbs-db | {"t":{"$date":"2022-08-16T10:33:03.520+00:00"},"s":"I",  "c":"FTDC",     "id":20625,   "ctx":"initandlisten","msg":"Initializing full-time diagnostic data capture","attr":{"dataDirectory":"/data/db/diagnostic.data"}}                               
xbs-db | {"t":{"$date":"2022-08-16T10:33:03.523+00:00"},"s":"I",  "c":"NETWORK",  "id":23015,   "ctx":"listener","msg":"Listening on","attr":{"address":"/tmp/mongodb-27017.sock"}}                                  
xbs-db | {"t":{"$date":"2022-08-16T10:33:03.523+00:00"},"s":"I",  "c":"NETWORK",  "id":23015,   "ctx":"listener","msg":"Listening on","attr":{"address":"0.0.0.0"}}
xbs-db | {"t":{"$date":"2022-08-16T10:33:03.523+00:00"},"s":"I",  "c":"NETWORK",  "id":23016,   "ctx":"listener","msg":"Waiting for connections","attr":{"port":27017,"ssl":"off"}}                                  
xbs-api | {"name":"xBrowserSync_api","hostname":"d8895449fdc4","pid":1,"level":50,"req":null,"err":{"message":"Server selection timed out after 30000 ms","name":"MongooseServerSelectionError","stack":"MongooseServerSelectionError: Server selection timed out after 30000 ms\n    at NativeConnection.Connection.openUri (/usr/src/api/node_modules/mongoose/lib/connection.js:845:32)\n    at /usr/src/api/node_modules/mongoose/lib/index.js:348:10\n    at /usr/src/api/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:5\n    at new Promise (<anonymous>)\n    at promiseOrCallback (/usr/src/api/node_modules/mongoose/lib/helpers/promiseOrCallback.js:30:10)\n    at Mongoose._promiseOrCallback (/usr/src/api/node_modules/mongoose/lib/index.js:1152:10)\n    at Mongoose.connect (/usr/src/api/node_modules/mongoose/lib/index.js:347:20)\n    at Object.connect (/usr/src/api/dist/db.js:55:34)\n    at Object.createApplication (/usr/src/api/dist/server.js:64:18)\n    at /usr/src/api/dist/api.js:6:32\n    at Object.<anonymous> (/
usr/src/api/dist/api.js:8:3)\n    at Module._compile (internal/modules/cjs/loader.js:1063:30)\n    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)\n    at Module.load (internal/modules/cjs/loader.js:928:32)\n    at Function.Module._load (internal/modules/cjs/loader.js:769:14)\n    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)"},"msg":"Unable to connect to database","time":"2022-08-16T10:33:28.849Z","v":0}
^CGracefully stopping... (press Ctrl+C again to force)
Stopping xbs-api ... done
Stopping xbs-db  ... done

My settings.
.env:

#API_HOSTNAME=xbsapi.yourdomain.org
DB_NAME=xbrowsersync
DB_PASSWORD=my_pass
DB_USERNAME=user
COMPOSE_CONVERT_WINDOWS_PATHS=1

settings.json:

{
  "db": {
    "host": "db"
  },
  "status": {
  "message": "xBrowserSync!"
  },
  "dailyNewSyncsLimit": 30,
  "maxSyncSize": 104857600,
}

docker-compose.yml:

version: "3.7"

services:
  db:
    container_name: "xbs-db"
    environment:
      - "MONGO_INITDB_DATABASE=$DB_NAME"
      - "MONGO_INITDB_ROOT_PASSWORD=$DB_PASSWORD"
      - "MONGO_INITDB_ROOT_USERNAME=$DB_USERNAME"
      - "XBS_DB_NAME=$DB_NAME"
      - "XBS_DB_PASSWORD=$DB_PASSWORD"
      - "XBS_DB_USERNAME=$DB_USERNAME"
    image: "mongo:4.4.4"
    restart: "unless-stopped"
    volumes:
      - "./xbs-db-data:/data/db"
      - "./xbs-db-backups:/data/backups"
      - "./mongoconfig.js:/docker-entrypoint-initdb.d/mongoconfig.js"
  api:
    container_name: "xbs-api"
    depends_on:
      - "db"
    environment:
      - "XBROWSERSYNC_DB_PWD=$DB_PASSWORD"
      - "XBROWSERSYNC_DB_USER=$DB_USERNAME"
    healthcheck:
      test: [ "CMD", "node", "/usr/src/api/healthcheck.js" ]
      interval: "1m"
      timeout: "10s"
      retries: "5"
      start_period: "30s"
    image: "xbrowsersync/api:1.1.13"
    ports:
      - "8080:8080"
    restart: "unless-stopped"
    volumes:
      - "./settings.json:/usr/src/api/config/settings.json"
      - "./healthcheck.js:/usr/src/api/healthcheck.js"
  #reverse-proxy:
    #command: "caddy reverse-proxy --from $API_HOSTNAME --to api:8080"
    #container_name: "xbs-reverse-proxy"
    #depends_on:
      #- "api"
    #image: "caddy:2.3.0-alpine"
    #ports:
      #- "443:443"
      #- "80:80"
    #restart: "unless-stopped"
    #volumes:
      #- "xbs-caddy-config:/config"
      #- "xbs-caddy-data:/data"

#volumes:
  #xbs-caddy-config:
  #xbs-caddy-data:
  #xbs-db-backups:
  #xbs-db-data:

I didn't change the files, healthcheck.js and mongoconfig.js.

@mad-max-traveller
Copy link

Hello. I encountered a similar problem, but under different conditions. I wanted to raise the service using Docker on my local network. The first step I set up everything on my work computer. I removed the reverse-proxy as I don't need it. And successfully started the xbrowsersync service on my computer. I installed the addon in my browser and set up the sync, everything works great. The second step I decided to move the xbrowsersync service to my server on the local network. I just copied the configuration files and ran them with $ sudo docker-compose up After that I got an error:

I figured out what the problem is, maybe it will help someone else too.
Installed but not used nftables blocks access to the Docker network!

@rudolphh
Copy link

rudolphh commented Dec 8, 2022

settings.json:

{
  "db": {
    "host": "db"
  },
  "status": {
  "message": "xBrowserSync!"
  },
  "dailyNewSyncsLimit": 30,
  "maxSyncSize": 104857600,
}

I didn't change the files, healthcheck.js and mongoconfig.js.

You have a trailing comma in your json which would be a syntax error (for JSON), but my files are otherwise the same as yours and xbs-api just won't start. I did the same as is recommended in #13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants