neilenns / node-deepstackai-trigger

Detects motion using Deepstack AI and calls registered triggers based on trigger rules.
MIT License
167 stars 28 forks source link

cannot start on command line or automatically in Docker #329

Closed stevearmitage closed 4 years ago

stevearmitage commented 4 years ago

What trouble are you having?

I installed and it worked ok. I restarted and could not get it working again!

I'm not sure how to start automatically

Have you tried with the sample files?

Have you tried the steps in the troubleshooting guide?

https://github.com/danecreekphotography/node-deepstackai-trigger/wiki/Troubleshooting

Log entries

I get the following error messages repeated

trigger_1 | 2020-06-29T15:28:32+08:00 [Main] Starting up version 5.0.0 trigger_1 | 2020-06-29T15:28:32+08:00 [Main] Timezone offset is -480 trigger_1 | 2020-06-29T15:28:32+08:00 [Main] Current time is Mon Jun 29 2020 15:28:32 GMT+0800 (Australian Western Standard Time) trigger_1 | 2020-06-29T15:28:33+08:00 [Settings] Unable to read the configuration file: EPERM: operation not permitted, open '/run/secrets/settings'. trigger_1 | 2020-06-29T15:28:33+08:00 [Settings] Unable to read the configuration file: ENOENT: no such file or directory, open '/config/settings.json'. trigger_1 | 2020-06-29T15:28:33+08:00 [Main] Unable to find any settings file. trigger_1 | 2020-06-29T15:28:33+08:00 [Main] **** trigger_1 | 2020-06-29T15:28:33+08:00 [Main] Startup cancelled due to errors. For troubleshooting assistance see https://github.com/danecreekphotography/node-deepstackai-trigger/wiki/Troubleshooting.

Installation details

I used the basic docker 'getting-started' I did not clone this repository...

Additional context

Add any other context about the problem here.

neilenns commented 4 years ago

Please post the entire contents of your docker-compose.yml file. It can't find the settings file so nothing can start up.

stevearmitage commented 4 years ago

Here is my docker-compose.yaml:

version: "3.8"
services:
  trigger:
    volumes:
      # Change d:/myfolder/myimages to point to the folder that will have the images
      # to analyze. Only change the local path that is before the :/aiinput portion.
      # Don't change the :/aiinput part. For example, if you are on Windows and your
      # images are stored locally in d:/blueiris/capturedImages your final line should
      # look like this:
      # d:/blueIris/capturedImages:/aiinput
      - e:/BlueIris/ai-input:/aiinput

    environment:
      # Change this to match the timezone the images are produced in,
      # Typically this will be the timezone of the machine running
      # the Docker container. For a list of valid timezone values
      # see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones.
      # The value to use is in the "TZ database name" column.
      - TZ=Australia/Perth

    ports:
      # This port is used by the local web server when annotated images are enabled.
      # If you change the port used by the local web server in the settings.json file
      # this also has to change to match.
      - 4242:4242

    # ------------------------------------------------------------------------
    # Don't change anything below this line unless you know what you are doing
    secrets:
      - triggers
      - settings
    image: danecreekphotography/node-deepstackai-trigger:latest
    restart: always
    depends_on:
      - deepstack-ai

  deepstack-ai:
    image: deepquestai/deepstack:latest
    restart: always
    volumes:
      - localstorage:/datastore
    environment:
      - VISION-DETECTION=True

volumes:
  localstorage:

secrets:
  settings:
    # This should point to the location of the settings.json configuration file
    file: ./settings.json
  triggers:
    # This should point to the location of the triggers.json configuration file
    file: ./triggers.json
stevearmitage commented 4 years ago

settings.json

{
  // Leave this line alone. It enables Intellisense when editing this file in Visual Studio Code.
  "$schema": "https://raw.githubusercontent.com/danecreekphotography/node-deepstackai-trigger/main/src/schemas/settings.schema.json",

  // This is the default uri for Deepstack when deploying using the docker-compose.yaml file
  // provided in this sampleConfiguration folder. If you have another deployment of Deepstack
  // running elsewhere change this setting to point to the correction location.
  "deepstackUri": "http://deepstack-ai:5000/",

  // Enables verbose logging. Useful when setting up the system to ensure
  // everything is running correctly.
  "verbose": true,

  // Provides the configuration details for your MQTT server. To enable
  // mqtt set the uri, username (if required), password (if required),
  // and set enabled to true.
  "mqtt": {
    "uri": "mqtt://mqtt.armitage.ws:1883",
    "username": "[USERNAME]",
    "password": "[PASSWORD]",
    "enabled": true
  },

  // Provides the configuration details for Telegram bot messages.
  // Set the botToken and enabled to true to use Telegram.
  "telegram": {
    "botToken": "insert bot token here",
    "enabled": false
  },

  // Provides the configuration details for Pushbullet notifications.
  // Set the accessToken and enabled to true to use Pushbullet.
  "pushbullet": {
    "accessToken": "access token here",
    "enabled": false
  },

  // Provides the configuration details for Pushover notifications.
  // Set the apiKey, userKey, and enabled to true to use Pushover.
  "pushover": {
    "apiKey": "api key here",
    "userKey": "user key here",
    "enabled": false
  }
}
stevearmitage commented 4 years ago

triggers.json:

{
  "$schema": "https://raw.githubusercontent.com/danecreekphotography/node-deepstackai-trigger/main/src/schemas/triggerConfiguration.schema.json",
  "triggers": [
    {
      "name": "Driveway detector",
      "watchPattern": "/aiinput/driveai.*.jpg",
      "enabled": true,
      "threshold": {
        "minimum": 10,
        "maximum": 100
      },
      "handlers": {
        "webRequest": {
          "triggerUris": ["http://william.armitage.ws/admin?trigger&camera=drive&user=xxxx&pw=yyyy"]
        },
        "mqtt": {
          "topic": "aimotion/trigger/driveway"
        },
        "telegram": {
          "chatIds": [1]
        }
      },
      "watchObjects": ["person"]
    },
    {
      "name": "Front door detector",
      "watchPattern": "/aiinput/ai_fd.*.jpg",
      "enabled": true,
      "threshold": {
        "minimum": 50,
        "maximum": 100
      },
      "handlers": {
        "webRequest": {
          "triggerUris": ["http://william.armitage.ws/admin?trigger&camera=fd&user=xxxx&pw=yyyy"]
        },
        "mqtt": {
          "topic": "aimotion/trigger/front-door"
        },
        "telegram": {
          "chatIds": [1]
        }
      },
      "watchObjects": ["person"]
    },
    {
      "name": "Front garden detector",
      "watchPattern": "/aiinput/fg_ai.*.jpg",
      "enabled": true,
      "threshold": {
        "minimum": 0,
        "maximum": 100
      },
      "handlers": {
        "webRequest": {
          "triggerUris": ["http://william.armitage.ws/admin?trigger&camera=fg&user=xxxx&pw=yyyy"]
        },
        "mqtt": {
          "topic": "aimotion/trigger/front-garden"
        },
        "telegram": {
          "chatIds": [1]
        }
      },
      "watchObjects": ["person"]
    },
    {
      "name": "Garage doors detector",
      "watchPattern": "/aiinput/garage1ai.*.jpg",
      "enabled": true,
      "threshold": {
        "minimum": 0,
        "maximum": 100
      },
      "handlers": {
        "webRequest": {
          "triggerUris": ["http://william.armitage.ws/admin?trigger&camera=rg1&user=xxxx&pw=yyyy"]
        },
        "mqtt": {
          "topic": "aimotion/trigger/garage-doors"
        },
        "telegram": {
          "chatIds": [1]
        }
      },
      "watchObjects": ["person","car","truck"]
    },
    {
      "name": "Garage rear detector",
      "watchPattern": "/aiinput/garage2ai.*.jpg",
      "enabled": true,
      "threshold": {
        "minimum": 70,
        "maximum": 100
      },
      "handlers": {
        "webRequest": {
          "triggerUris": ["http://william.armitage.ws/admin?trigger&camera=rg2&user=xxxx&pw=yyyy"]
        },
        "mqtt": {
          "topic": "aimotion/trigger/garage-rear"
        },
        "telegram": {
          "chatIds": [1]
        }
      },
      "watchObjects": ["person","car","truck"]
    },
    {
      "name": "Patio detector",
      "watchPattern": "/aiinput/patioai.*.jpg",
      "enabled": true,
      "threshold": {
        "minimum": 70,
        "maximum": 100
      },
      "handlers": {
        "webRequest": {
          "triggerUris": ["http://william.armitage.ws/admin?trigger&camera=patio&user=xxxx&pw=yyyy"]
        },
        "mqtt": {
          "topic": "aimotion/trigger/patio"
        },
        "telegram": {
          "chatIds": [1]
        }
      },
      "watchObjects": ["person"]
    },
    {
      "name": "Workshop",
      "watchPattern": "/aiinput/workai.*.jpg",
      "enabled": true,
      "threshold": {
        "minimum": 70,
        "maximum": 100
      },
      "handlers": {
        "webRequest": {
          "triggerUris": ["http://william.armitage.ws/admin?trigger&camera=workshop&user=xxxx&pw=yyyy"]
        },
        "mqtt": {
          "topic": "aimotion/trigger/workshop"
        },
        "telegram": {
          "chatIds": [1]
        }
      },
      "watchObjects": ["person"]
    },
    {
      "name": "Sidewalk detector",
      "watchPattern": "/aiinput/sideai*.jpg",
      "enabled": true,
      "threshold": {
        "minimum": 0,
        "maximum": 100
      },
      "handlers": {
        "webRequest": {
          "triggerUris": ["http://william.armitage.ws/admin?trigger&camera=side&user=xxxx&pw=yyyy"]
        },
        "mqtt": {
          "messages": [{ "topic": "aimotion/triggers/sidewalk" }]
        },
        "pushover": {
          "userKeys": ["1"]
        },
        "telegram": {
          "chatIds": [1],
          "annotateImage": true
        }
      },
      "watchObjects": ["person"]
    }
  ]
}
neilenns commented 4 years ago

Thanks!

It can't find your settings file. Make sure settings.json and triggers.json are in the same folder as your docker-compose.yml file, and that you are running docker-compose up from inside the folder that has the .yml file in it.

stevearmitage commented 4 years ago

C:\Users\micro\getting-started>dir

 Volume in drive C has no label.
 Volume Serial Number is 50C2-4B1D

 Directory of C:\Users\micro\getting-started

29/06/2020  13:30    <DIR>          .
29/06/2020  13:30    <DIR>          ..
29/06/2020  13:14                12 .dockerignore
29/06/2020  13:14                14 .gitignore
29/06/2020  13:14    <DIR>          app
29/06/2020  13:14               293 build.sh
29/06/2020  13:26             1,944 docker-compose.yml
29/06/2020  13:14             1,001 Dockerfile
29/06/2020  13:14    <DIR>          docs
29/06/2020  13:14            11,556 LICENSE
29/06/2020  13:14             2,071 mkdocs.yml
29/06/2020  13:14             1,719 README.md
29/06/2020  13:14               110 requirements.txt
29/06/2020  13:52             1,706 settings.json
29/06/2020  13:45             4,818 triggers.json
29/06/2020  13:14                90 yarn.lock
              12 File(s)         25,334 bytes
               4 Dir(s)  819,786,305,536 bytes free

C:\Users\micro\getting-started>docker-compose up

Starting getting-started_deepstack-ai_1 ... done                                                                                                                        Starting getting-started_trigger_1      ... done                                                                                                                        Attaching to getting-started_deepstack-ai_1, getting-started_trigger_1
deepstack-ai_1  | /v1/vision/detection
deepstack-ai_1  | ---------------------------------------
deepstack-ai_1  | v1/vision/addmodel
deepstack-ai_1  | ---------------------------------------
deepstack-ai_1  | v1/vision/listmodels
deepstack-ai_1  | ---------------------------------------
deepstack-ai_1  | v1/vision/deletemodel
deepstack-ai_1  | ---------------------------------------
deepstack-ai_1  | ---------------------------------------
deepstack-ai_1  | v1/backup
deepstack-ai_1  | ---------------------------------------
deepstack-ai_1  | v1/restore
trigger_1       | 2020-06-30T10:48:21+08:00 [Main] Starting up version 5.0.0
trigger_1       | 2020-06-30T10:48:21+08:00 [Main] Timezone offset is -480
trigger_1       | 2020-06-30T10:48:21+08:00 [Main] Current time is Tue Jun 30 2020 10:48:21 GMT+0800 (Australian Western Standard Time)
trigger_1       | 2020-06-30T10:48:21+08:00 [Settings] Unable to read the configuration file: EPERM: operation not permitted, open '/run/secrets/settings'.
trigger_1       | 2020-06-30T10:48:21+08:00 [Settings] Unable to read the configuration file: ENOENT: no such file or directory, open '/config/settings.json'.
trigger_1       | 2020-06-30T10:48:21+08:00 [Main] Unable to find any settings file.
trigger_1       | 2020-06-30T10:48:21+08:00 [Main] ****************************************
trigger_1       | 2020-06-30T10:48:21+08:00 [Main] Startup cancelled due to errors. For troubleshooting assistance see https://github.com/danecreekphotography/node-deepstackai-trigger/wiki/Troubleshooting.
Gracefully stopping... (press Ctrl+C again to force)
Stopping getting-started_trigger_1      ... done                                                                                                                        Stopping getting-started_deepstack-ai_1 ... done                                                                                                                        
C:\Users\micro\getting-started>
stevearmitage commented 4 years ago

Would it help to create a new 'docker' instance - I'm not familiar with Docker, so created the 'getting started' instance

Also see I need 3 quotes to show the content in code format - using the 'insert code' button only add's one.

Thanks for your help. Steve

neilenns commented 4 years ago

Try creating a new folder that just has three files in it:

stevearmitage commented 4 years ago

That looks better - thanks!

Will this start automatically from now on, or how do I enable that?

trigger_1       | 2020-06-30T10:55:43+08:00 [Trigger Workshop] /aiinput/workai.20200630_104138656.jpg: Skipping as it was created before the service started.
trigger_1       | 2020-06-30T10:55:52+08:00 [Trigger Front garden detector] /aiinput/fg_ai.20200630_105551866.jpg: Analyzing
deepstack-ai_1  | [GIN] 2020/06/30 - 02:55:54 | 200 |  1.981490811s |      172.19.0.3 | POST     /v1/vision/detection
trigger_1       | 2020-06-30T10:55:54+08:00 [Trigger Front garden detector] /aiinput/fg_ai.20200630_105551866.jpg: Found at least one object in the photo. (1995 ms)
trigger_1       | 2020-06-30T10:55:54+08:00 [Trigger Front garden detector] /aiinput/fg_ai.20200630_105551866.jpg: Detected object car is not in the watch objects list [person]
trigger_1       | 2020-06-30T10:55:54+08:00 [Trigger Front garden detector] /aiinput/fg_ai.20200630_105551866.jpg: Not triggered by car (86.70183)
trigger_1       | 2020-06-30T10:55:57+08:00 [Trigger Front garden detector] /aiinput/fg_ai.20200630_105556885.jpg: Analyzing
deepstack-ai_1  | [GIN] 2020/06/30 - 02:55:57 | 200 |  404.803201ms |      172.19.0.3 | POST     /v1/vision/detection
trigger_1       | 2020-06-30T10:55:57+08:00 [Trigger Front garden detector] /aiinput/fg_ai.20200630_105556885.jpg: Found at least one object in the photo. (411 ms)
trigger_1       | 2020-06-30T10:55:57+08:00 [Trigger Front garden detector] /aiinput/fg_ai.20200630_105556885.jpg: Detected object car is not in the watch objects list [person]
trigger_1       | 2020-06-30T10:55:57+08:00 [Trigger Front garden detector] /aiinput/fg_ai.20200630_105556885.jpg: Not triggered by car (49.0652)
trigger_1       | 2020-06-30T10:55:57+08:00 [Trigger Front garden detector] /aiinput/fg_ai.20200630_105556885.jpg: Detected object traffic light is not in the watch objects list [person]
trigger_1       | 2020-06-30T10:55:57+08:00 [Trigger Front garden detector] /aiinput/fg_ai.20200630_105556885.jpg: Not triggered by traffic light (53.5648)
neilenns commented 4 years ago

Great!

It's set to auto-start by default, using the following lines in the docker-compose.yml file:

  • restart: always

Since you know it's working now what I suggest doing is starting it up in the background. Do a ctrl+c to kill off the running version in your command line window, then run this:

docker-compose up -d

The -d option will make it run in the background. To see logs and whatnot after that use the Docker Desktop app, which is obnoxiously hiding in the system tray. Right click on the Docker icon then pick Dashboard from the menu. From there you'll see the running containers and can click into the trigger container to see the logs that way.

stevearmitage commented 4 years ago

You sir, are a star.

I was trying to start the docker desktop and expected to see a console and 'nothing happened'. Your pointer to the system tray was perfect. 👯‍♀️

neilenns commented 4 years ago

It is the most infuriating and confusing UI I've encountered in ages. Drives me nuts every time!