Last Watch AI - a new platform-independent AI tool with web interface

Hi Guys,

I've been trying with no success to get this tool working. Here's a summary of what I've got so far and what I've done.

Setup:

All VM's running on Proxmox on a Dell R710
BI running on a Win10 Pro VM - runs fine (CPU ~50%, RAM ~20%)
3x 4K cams with 2 streams each
Docker running on a Ubuntu server 20.04.2 LTS VM

Originally, I went through all the setup without creating a non-root user. I could access the web UI and everything was going very well, until I couldn't access the watch folder from my BI machine. Every time I tried again after that, I can't access the web UI. No matter what I try, I keep getting "error_500" on the web page.

I've spun up more fresh VMs in the last 2 days than I'd care to admit. Tried all types of different VM settings, but always following the "Setup Guide with Blue Iris" in the OP.

Any pointers would be helpful. Let me know if you want any log files or other outputs.

I'm not a computer professional and Just started learning Linux a few months ago. The instructions in the setup guide are very good and I feel like I should be able to get this working, with your help of course. I'm really liking learning Linux and this is a great project to further my skills.

Thanks for putting this together and for your help.

EDIT: I'm trying to access the web UI on port 5555, which seems to be correct based on the docker ports. I previously had portainer also running and had no problem accessing it on it's own port on the same IP address. Here's the list of containers I have running now:

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
31587a57b3ae nginx:stable "/docker-entrypoint.…" 12 hours ago Up 12 hours 0.0.0.0:5555->80/tcp lw_nginx
6577d6f80e8b mcuadros/ofelia:latest"/usr/bin/ofelia dae…" 12 hours ago Up 12 hours lw_scheduler
020640cec6eb last-watch-ai_php "docker-php-entrypoi…" 12 hours ago Up 12 hours 0.0.0.0:9000->9000/tcp lw_php
1636d95b62d3 akmolina28/laravel-queue-worker "/bin/sh /usr/local/…" 12 hours ago Up 12 hours lw_queue
90c084155ccb deepquestai/deepstack "/app/server/server" 12 hours ago Up 12 hours 0.0.0.0:5001->5000/tcp lw_deepstack
51df9deb8be2 akmolina28/webhook-folder-watcher "docker-entrypoint.s…" 12 hours ago Up 12 hours lw_watcher
81998f3155a3 mysql:5.7.29 "docker-entrypoint.s…" 16 hours ago Up 16 hours 0.0.0.0:3306->3306/tcp, 33060/tcp lw_mysql
 
Last edited:
I can't find any good resources on how to run Deepstack-GPU using docker-compose, but you should be able to run Deepstack separately. Just remove the deepstack service from docker-compose.yml so that it does not start as a dependency for Last Watch. That way you can start the Deepstack-GPU service on your own using whatever parameters you want. You will also have to change the DEEPSTACK_BASE_URL setting in src/.env to something like http://localhost:5000 instead of the internal docker service address. After you change those two files you would have to restart the containers.


Heyhey,

i modified the compose file and removed dependency on deepstack and the deepstack itself.
Then i installed deepstack windows gpu version and i run it with all APIs (vision-scene, vision-detection, vision-face) at port 5000

Deepstack is running fine and reachable under localhost:5000

i changed env-file to adress not deepstack:5000 but localhost:5000

I can see log file entries about deepstack in last-watch, but no response of Deepstack and no "Run Time"



Another issue is that after stopping the containers and restarting, i get alot of errors. It seems that only after hitting the compose-command, everything starts up well



Any ideas?


It looks like that LastWatch doesnt care if my Deepstack instance is running or not. I also dont see any difference in the logs (via localhost:8080/deepstackLogs or Docker when having Deepstack running or not.
Maybe i need to change something somewhere, so the Events are posted to Deepstack Instance which now is not running in docker anymore



EDIT: I tried the classic AI-Tool which worked fine. Not sure if i can improve AI Response (DeepStack log showed 500ms), expected it faster with RTX-Card :)
 
Last edited:
Hi Guys,

I've been trying with no success to get this tool working. Here's a summary of what I've got so far and what I've done.

Setup:

All VM's running on Proxmox on a Dell R710
BI running on a Win10 Pro VM - runs fine (CPU ~50%, RAM ~20%)
3x 4K cams with 2 streams each
Docker running on a Ubuntu server 20.04.2 LTS VM

Originally, I went through all the setup without creating a non-root user. I could access the web UI and everything was going very well, until I couldn't access the watch folder from my BI machine. Every time I tried again after that, I can't access the web UI. No matter what I try, I keep getting "error_500" on the web page.

I've spun up more fresh VMs in the last 2 days than I'd care to admit. Tried all types of different VM settings, but always following the "Setup Guide with Blue Iris" in the OP.

Any pointers would be helpful. Let me know if you want any log files or other outputs.

I'm not a computer professional and Just started learning Linux a few months ago. The instructions in the setup guide are very good and I feel like I should be able to get this working, with your help of course. I'm really liking learning Linux and this is a great project to further my skills.

Thanks for putting this together and for your help.

EDIT: I'm trying to access the web UI on port 5555, which seems to be correct based on the docker ports. I previously had portainer also running and had no problem accessing it on it's own port on the same IP address. Here's the list of containers I have running now:

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
31587a57b3ae nginx:stable "/docker-entrypoint.…" 12 hours ago Up 12 hours 0.0.0.0:5555->80/tcp lw_nginx
6577d6f80e8b mcuadros/ofelia:latest"/usr/bin/ofelia dae…" 12 hours ago Up 12 hours lw_scheduler
020640cec6eb last-watch-ai_php "docker-php-entrypoi…" 12 hours ago Up 12 hours 0.0.0.0:9000->9000/tcp lw_php
1636d95b62d3 akmolina28/laravel-queue-worker "/bin/sh /usr/local/…" 12 hours ago Up 12 hours lw_queue
90c084155ccb deepquestai/deepstack "/app/server/server" 12 hours ago Up 12 hours 0.0.0.0:5001->5000/tcp lw_deepstack
51df9deb8be2 akmolina28/webhook-folder-watcher "docker-entrypoint.s…" 12 hours ago Up 12 hours lw_watcher
81998f3155a3 mysql:5.7.29 "docker-entrypoint.s…" 16 hours ago Up 16 hours 0.0.0.0:3306->3306/tcp, 33060/tcp lw_mysql

I'm also running everything in a Ubuntu container in Proxmox, so you definitely should be able to get this working. The first thing that jumps out to me is that you might have permissions issues on the watch folder and/or the application. File permissions are usually the hardest thing for people who are new to Linux.

The first thing I would do is enable application debugging by setting APP_DEBUG=true in src/.env. Note that this is not the root level .env file, it's one level deeper in the src folder. After that, refresh the page and see if you get an error screen instead of an empty 500 error. Alternatively, you can also check the logs in src/storage/logs/laravel.log. Hopefully you get a useful error stack that you can resolve on your own or reply back here with. If you don't get an error message from the application itself, then the issue is deeper in the stack. You'll have to dig into the php and nginx logs.

One more tip to help you get this working -- divide and conquer. Try to get it working without the samba share first. Before setting up samba, try dropping an image into the watch folder and see if Last Watch creates a detection event and make sure you can see the image in the web UI. I would just find an image on the web and use wget to download it into the watch folder.
If you can see the image in Last Watch, that would tell you that you set the application up correctly. Next, when you set up samba, if everything breaks again then you know something went wrong during the samba setup.
 
Heyhey,

i modified the compose file and removed dependency on deepstack and the deepstack itself.
Then i installed deepstack windows gpu version and i run it with all APIs (vision-scene, vision-detection, vision-face) at port 5000

Deepstack is running fine and reachable under localhost:5000

i changed env-file to adress not deepstack:5000 but localhost:5000

I can see log file entries about deepstack in last-watch, but no response of Deepstack and no "Run Time"



Another issue is that after stopping the containers and restarting, i get alot of errors. It seems that only after hitting the compose-command, everything starts up well



Any ideas?


It looks like that LastWatch doesnt care if my Deepstack instance is running or not. I also dont see any difference in the logs (via localhost:8080/deepstackLogs or Docker when having Deepstack running or not.
Maybe i need to change something somewhere, so the Events are posted to Deepstack Instance which now is not running in docker anymore



EDIT: I tried the classic AI-Tool which worked fine. Not sure if i can improve AI Response (DeepStack log showed 500ms), expected it faster with RTX-Card :)

Okay, I think the issue is how you are referencing services running on the host machine. Localhost does not reference the host machine, it references the container. Looking around on google it looks like there are a few different ways to do this:

(1) Try using the IP 172.17.0.1 (i.e. set the deepstack base url to . This url does resolve for me on Linux, but it did not on windows.

(2) Alternatively, try using the special DNS host.docker.internal according to Networking features in Docker Desktop for Windows . I just tried this on my windows machine and the host name did resolve. Supposedly this works on Mac too. Try setting your base url to .

(3) Try adding the host option to the services in docker-compose so that they share the same network as the host (Option network_mode: host in docker compose file not working as expected). This would be harder to set up I think but it would allow you to use "localhost" or "127.0.0.1" to hit services on the host.

Also note that the Last Watch application does not care how you run Deepstack. It is completely independent, in fact you could use a different AI engine if you wanted to. If deepstack isn't running you won't have any issues starting up the rest of the application, so that's to be expected. The only time you would see errors is when the app attempts to call deepstack and the service is not running at the url specified in the .env file.
 
Last edited:
I'm also running everything in a Ubuntu container in Proxmox, so you definitely should be able to get this working. The first thing that jumps out to me is that you might have permissions issues on the watch folder and/or the application. File permissions are usually the hardest thing for people who are new to Linux.

The first thing I would do is enable application debugging by setting APP_DEBUG=true in src/.env. Note that this is not the root level .env file, it's one level deeper in the src folder. After that, refresh the page and see if you get an error screen instead of an empty 500 error. Alternatively, you can also check the logs in src/storage/logs/laravel.log. Hopefully you get a useful error stack that you can resolve on your own or reply back here with. If you don't get an error message from the application itself, then the issue is deeper in the stack. You'll have to dig into the php and nginx logs.

One more tip to help you get this working -- divide and conquer. Try to get it working without the samba share first. Before setting up samba, try dropping an image into the watch folder and see if Last Watch creates a detection event and make sure you can see the image in the web UI. I would just find an image on the web and use wget to download it into the watch folder.
If you can see the image in Last Watch, that would tell you that you set the application up correctly. Next, when you set up samba, if everything breaks again then you know something went wrong during the samba setup.

Thanks for the help. It's still not working, but I think I've made some progress (and learned a lot about the Linux file system!). The error screen now has more info that referst to the log file. It might as well be Russian. I can confirm that the same error persists before and after setting up the samba share. I am currently able to map the drive in windows, write files to it, and see those files in the terminal.

Any help is greatly appreciated.

The contents of laravel.log:

[2021-02-05 16:52:15] production.ERROR: getimagesize(): Read error! {"exception":"[object] (ErrorException(code: 0): getimagesize(): Read error! at /var/www/app/app/Factories/DetectionEventModelFactory.php:23)
[stacktrace]
#0 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(8, 'getimagesize():...', '/var/www/app/ap...', 23, Array)
#1 /var/www/app/app/Factories/DetectionEventModelFactory.php(23): getimagesize('/var/www/app/st...')
#2 /var/www/app/app/Jobs/ProcessWebhookJob.php(21): App\\Factories\\DetectionEventModelFactory::createFromImageFile('New Text Docume...', Object(Illuminate\\Support\\Carbon))
#3 [internal function]: App\\Jobs\\ProcessWebhookJob->handle(Object(Illuminate\\Support\\Carbon))
#4 /var/www/app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): call_user_func_array(Array, Array)
#5 /var/www/app/vendor/laravel/framework/src/Illuminate/Container/Util.php(37): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#6 /var/www/app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(95): Illuminate\\Container\\Util::unwrapIfClosure(Object(Closure))
#7 /var/www/app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(39): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#8 /var/www/app/vendor/laravel/framework/src/Illuminate/Container/Container.php(596): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#9 /var/www/app/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(94): Illuminate\\Container\\Container->call(Array)
#10 /var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Bus\\Dispatcher->Illuminate\\Bus\\{closure}(Object(App\\Jobs\\ProcessWebhookJob))
#11 /var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(App\\Jobs\\ProcessWebhookJob))
#12 /var/www/app/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(98): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#13 /var/www/app/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(83): Illuminate\\Bus\\Dispatcher->dispatchNow(Object(App\\Jobs\\ProcessWebhookJob), false)
#14 /var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Queue\\CallQueuedHandler->Illuminate\\Queue\\{closure}(Object(App\\Jobs\\ProcessWebhookJob))
#15 /var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(App\\Jobs\\ProcessWebhookJob))
#16 /var/www/app/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(85): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#17 /var/www/app/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(59): Illuminate\\Queue\\CallQueuedHandler->dispatchThroughMiddleware(Object(Illuminate\\Queue\\Jobs\\DatabaseJob), Object(App\\Jobs\\ProcessWebhookJob))
#18 /var/www/app/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(98): Illuminate\\Queue\\CallQueuedHandler->call(Object(Illuminate\\Queue\\Jobs\\DatabaseJob), Array)
#19 /var/www/app/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(356): Illuminate\\Queue\\Jobs\\Job->fire()
#20 /var/www/app/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(306): Illuminate\\Queue\\Worker->process('database', Object(Illuminate\\Queue\\Jobs\\DatabaseJob), Object(Illuminate\\Queue\\WorkerOptions))
#21 /var/www/app/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(132): Illuminate\\Queue\\Worker->runJob(Object(Illuminate\\Queue\\Jobs\\DatabaseJob), 'database', Object(Illuminate\\Queue\\WorkerOptions))
#22 /var/www/app/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(112): Illuminate\\Queue\\Worker->daemon('database', 'default', Object(Illuminate\\Queue\\WorkerOptions))
#23 /var/www/app/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(96): Illuminate\\Queue\\Console\\WorkCommand->runWorker('database', 'default')
#24 [internal function]: Illuminate\\Queue\\Console\\WorkCommand->handle()
#25 /var/www/app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): call_user_func_array(Array, Array)
#26 /var/www/app/vendor/laravel/framework/src/Illuminate/Container/Util.php(37): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#27 /var/www/app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(95): Illuminate\\Container\\Util::unwrapIfClosure(Object(Closure))
#28 /var/www/app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(39): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#29 /var/www/app/vendor/laravel/framework/src/Illuminate/Container/Container.php(596): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#30 /var/www/app/vendor/laravel/framework/src/Illuminate/Console/Command.php(134): Illuminate\\Container\\Container->call(Array)
#31 /var/www/app/vendor/symfony/console/Command/Command.php(258): Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#32 /var/www/app/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#33 /var/www/app/vendor/symfony/console/Application.php(916): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#34 /var/www/app/vendor/symfony/console/Application.php(264): Symfony\\Component\\Console\\Application->doRunCommand(Object(Illuminate\\Queue\\Console\\WorkCommand), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#35 /var/www/app/vendor/symfony/console/Application.php(140): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#36 /var/www/app/vendor/laravel/framework/src/Illuminate/Console/Application.php(93): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#37 /var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#38 /var/www/app/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#39 {main}
"}
 
Thanks for the help. It's still not working, but I think I've made some progress (and learned a lot about the Linux file system!). The error screen now has more info that referst to the log file. It might as well be Russian. I can confirm that the same error persists before and after setting up the samba share. I am currently able to map the drive in windows, write files to it, and see those files in the terminal.

Any help is greatly appreciated.

The contents of laravel.log:

[2021-02-05 16:52:15] production.ERROR: getimagesize(): Read error! {"exception":"[object] (ErrorException(code: 0): getimagesize(): Read error! at /var/www/app/app/Factories/DetectionEventModelFactory.php:23)
[stacktrace]
#0 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(8, 'getimagesize():...', '/var/www/app/ap...', 23, Array)
#1 /var/www/app/app/Factories/DetectionEventModelFactory.php(23): getimagesize('/var/www/app/st...')
#2 /var/www/app/app/Jobs/ProcessWebhookJob.php(21): App\\Factories\\DetectionEventModelFactory::createFromImageFile('New Text Docume...', Object(Illuminate\\Support\\Carbon))
#3 [internal function]: App\\Jobs\\ProcessWebhookJob->handle(Object(Illuminate\\Support\\Carbon))
#4 /var/www/app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): call_user_func_array(Array, Array)
#5 /var/www/app/vendor/laravel/framework/src/Illuminate/Container/Util.php(37): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#6 /var/www/app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(95): Illuminate\\Container\\Util::unwrapIfClosure(Object(Closure))
#7 /var/www/app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(39): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#8 /var/www/app/vendor/laravel/framework/src/Illuminate/Container/Container.php(596): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#9 /var/www/app/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(94): Illuminate\\Container\\Container->call(Array)
#10 /var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Bus\\Dispatcher->Illuminate\\Bus\\{closure}(Object(App\\Jobs\\ProcessWebhookJob))
#11 /var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(App\\Jobs\\ProcessWebhookJob))
#12 /var/www/app/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(98): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#13 /var/www/app/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(83): Illuminate\\Bus\\Dispatcher->dispatchNow(Object(App\\Jobs\\ProcessWebhookJob), false)
#14 /var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Queue\\CallQueuedHandler->Illuminate\\Queue\\{closure}(Object(App\\Jobs\\ProcessWebhookJob))
#15 /var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(App\\Jobs\\ProcessWebhookJob))
#16 /var/www/app/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(85): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#17 /var/www/app/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(59): Illuminate\\Queue\\CallQueuedHandler->dispatchThroughMiddleware(Object(Illuminate\\Queue\\Jobs\\DatabaseJob), Object(App\\Jobs\\ProcessWebhookJob))
#18 /var/www/app/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(98): Illuminate\\Queue\\CallQueuedHandler->call(Object(Illuminate\\Queue\\Jobs\\DatabaseJob), Array)
#19 /var/www/app/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(356): Illuminate\\Queue\\Jobs\\Job->fire()
#20 /var/www/app/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(306): Illuminate\\Queue\\Worker->process('database', Object(Illuminate\\Queue\\Jobs\\DatabaseJob), Object(Illuminate\\Queue\\WorkerOptions))
#21 /var/www/app/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(132): Illuminate\\Queue\\Worker->runJob(Object(Illuminate\\Queue\\Jobs\\DatabaseJob), 'database', Object(Illuminate\\Queue\\WorkerOptions))
#22 /var/www/app/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(112): Illuminate\\Queue\\Worker->daemon('database', 'default', Object(Illuminate\\Queue\\WorkerOptions))
#23 /var/www/app/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(96): Illuminate\\Queue\\Console\\WorkCommand->runWorker('database', 'default')
#24 [internal function]: Illuminate\\Queue\\Console\\WorkCommand->handle()
#25 /var/www/app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): call_user_func_array(Array, Array)
#26 /var/www/app/vendor/laravel/framework/src/Illuminate/Container/Util.php(37): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#27 /var/www/app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(95): Illuminate\\Container\\Util::unwrapIfClosure(Object(Closure))
#28 /var/www/app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(39): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#29 /var/www/app/vendor/laravel/framework/src/Illuminate/Container/Container.php(596): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#30 /var/www/app/vendor/laravel/framework/src/Illuminate/Console/Command.php(134): Illuminate\\Container\\Container->call(Array)
#31 /var/www/app/vendor/symfony/console/Command/Command.php(258): Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#32 /var/www/app/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#33 /var/www/app/vendor/symfony/console/Application.php(916): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#34 /var/www/app/vendor/symfony/console/Application.php(264): Symfony\\Component\\Console\\Application->doRunCommand(Object(Illuminate\\Queue\\Console\\WorkCommand), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#35 /var/www/app/vendor/symfony/console/Application.php(140): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#36 /var/www/app/vendor/laravel/framework/src/Illuminate/Console/Application.php(93): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#37 /var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#38 /var/www/app/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#39 {main}
"}

Looks like you have two issues going on, I strongly suspect both are related to permissions.

(1) The errors in the log file indicate that Last Watch is unable to read images in the watch folder. The "Read error!" message is ambiguous and could mean the file is corrupted or not a jpg file, but I suspect that the error is due to permissions.

(2) I haven't seen the error from the web UI (please post that) but I have seen in the past where permissions errors cause an exception, and then laravel fails to log the exception because it does not have permissions to touch the log file. The error will indicate that it can't open the log. I'm guessing that's what is going on here.

Here are some steps you can take to totally reset the permissions:

  • First, as your sudo user, check your user/group ids by running id -u and id -g. If the IDs are different from 1000, you need to edit the .env file to set those. The first sudo user created on the system should be 1000 but double check just in case.
  • Set the permissions on your watch folder with sudo chown -R sambauser:sambauser /path/to/watch-folder && sudo chmod -R 755 /path/to/watch-folder
  • Set the permissions on the application files with sudo chown R sudouser:sudouser /path/to/last-watch-ai && sudo chmod -R 755 /path/to/last-watch-ai
* Replace "sambauser" with the user you used to set up samba, and "sudouser" with the name of your sudo user (those could both be the same user unless you set up samba with a different username)

  • Finally, restart the app with sudo docker compose down and then sudo docker-compose up -d --build site
 
Looks like you have two issues going on, I strongly suspect both are related to permissions.

(1) The errors in the log file indicate that Last Watch is unable to read images in the watch folder. The "Read error!" message is ambiguous and could mean the file is corrupted or not a jpg file, but I suspect that the error is due to permissions.

(2) I haven't seen the error from the web UI (please post that) but I have seen in the past where permissions errors cause an exception, and then laravel fails to log the exception because it does not have permissions to touch the log file. The error will indicate that it can't open the log. I'm guessing that's what is going on here.

Here are some steps you can take to totally reset the permissions:

  • First, as your sudo user, check your user/group ids by running id -u and id -g. If the IDs are different from 1000, you need to edit the .env file to set those. The first sudo user created on the system should be 1000 but double check just in case.
  • Set the permissions on your watch folder with sudo chown -R sambauser:sambauser /path/to/watch-folder && sudo chmod -R 755 /path/to/watch-folder
  • Set the permissions on the application files with sudo chown R sudouser:sudouser /path/to/last-watch-ai && sudo chmod -R 755 /path/to/last-watch-ai
* Replace "sambauser" with the user you used to set up samba, and "sudouser" with the name of your sudo user (those could both be the same user unless you set up samba with a different username)

  • Finally, restart the app with sudo docker compose down and then sudo docker-compose up -d --build site

Thanks again for the help. Here's the web UI error text:

UnexpectedValueException:
The stream or file "/var/www/app/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied

at /var/www/app/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:111
at Monolog\Handler\StreamHandler->write(array('message' => 'The stream or file "/var/www/app/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied', 'context' => array('exception' => object(UnexpectedValueException)), 'level' => 400, 'level_name' => 'ERROR', 'channel' => 'production', 'datetime' => object(DateTimeImmutable), 'extra' => array(), 'formatted' => '[2021-02-05 17:23:05] production.ERROR: The stream or file "/var/www/app/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied {"exception":"[object] (UnexpectedValueException(code: 0): The stream or file \\"/var/www/app/storage/logs/laravel.log\\" could not be opened in append mode: failed to open stream: Permission denied at /var/www/app/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:111)[stacktrace]#0 /var/www/app/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(42): Monolog\\\\Handler\\\\StreamHandler->write(Array)#1 /var/www/app/vendor/monolog/monolog/src/Monolog/Logger.php(325): Monolog\\\\Handler\\\\AbstractProcessingHandler->handle(Array)#2 /var/www/app/vendor/monolog/monolog/src/Monolog/Logger.php(543): Monolog\\\\Logger->addRecord(400, \'The stream or f...\', Array)#3 /var/www/app/vendor/laravel/framework/src/Illuminate/Log/Logger.php(174): Monolog\\\\Logger->error(\'The stream or f...\', Array)#4 /var/www/app/vendor/laravel/framework/src/Illuminate/Log/Logger.php(87): Illuminate\\\\Log\\\\Logger->writeLog(\'error\', \'The stream or f...\', Array)#5 /var/www/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(547): Illuminate\\\\Log\\\\Logger->error(\'The stream or f...\', Array)#6 /var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(122): Illuminate\\\\Log\\\\LogManager->error(\'The stream or f...\', Array)#7 /var/www/app/app/Exceptions/Handler.php(40): Illuminate\\\\Foundation\\\\Exceptions\\\\Handler->report(Object(UnexpectedValueException))#8 /var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(403): App\\\\Exceptions\\\\Handler->report(Object(UnexpectedValueException))#9 /var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(111): Illuminate\\\\Foundation\\\\Http\\\\Kernel->reportException(Object(UnexpectedValueException))#10 /var/www/app/public/index.php(53): Illuminate\\\\Foundation\\\\Http\\\\Kernel->handle(Object(Illuminate\\\\Http\\\\Request))#11 {main}"} '))
(/var/www/app/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php:42)
at Monolog\Handler\AbstractProcessingHandler->handle(array('message' => 'The stream or file "/var/www/app/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied', 'context' => array('exception' => object(UnexpectedValueException)), 'level' => 400, 'level_name' => 'ERROR', 'channel' => 'production', 'datetime' => object(DateTimeImmutable), 'extra' => array(), 'formatted' => '[2021-02-05 17:23:05] production.ERROR: The stream or file "/var/www/app/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied {"exception":"[object] (UnexpectedValueException(code: 0): The stream or file \\"/var/www/app/storage/logs/laravel.log\\" could not be opened in append mode: failed to open stream: Permission denied at /var/www/app/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:111)[stacktrace]#0 /var/www/app/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(42): Monolog\\\\Handler\\\\StreamHandler->write(Array)#1 /var/www/app/vendor/monolog/monolog/src/Monolog/Logger.php(325): Monolog\\\\Handler\\\\AbstractProcessingHandler->handle(Array)#2 /var/www/app/vendor/monolog/monolog/src/Monolog/Logger.php(543): Monolog\\\\Logger->addRecord(400, \'The stream or f...\', Array)#3 /var/www/app/vendor/laravel/framework/src/Illuminate/Log/Logger.php(174): Monolog\\\\Logger->error(\'The stream or f...\', Array)#4 /var/www/app/vendor/laravel/framework/src/Illuminate/Log/Logger.php(87): Illuminate\\\\Log\\\\Logger->writeLog(\'error\', \'The stream or f...\', Array)#5 /var/www/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(547): Illuminate\\\\Log\\\\Logger->error(\'The stream or f...\', Array)#6 /var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(122): Illuminate\\\\Log\\\\LogManager->error(\'The stream or f...\', Array)#7 /var/www/app/app/Exceptions/Handler.php(40): Illuminate\\\\Foundation\\\\Exceptions\\\\Handler->report(Object(UnexpectedValueException))#8 /var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(403): App\\\\Exceptions\\\\Handler->report(Object(UnexpectedValueException))#9 /var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(111): Illuminate\\\\Foundation\\\\Http\\\\Kernel->reportException(Object(UnexpectedValueException))#10 /var/www/app/public/index.php(53): Illuminate\\\\Foundation\\\\Http\\\\Kernel->handle(Object(Illuminate\\\\Http\\\\Request))#11 {main}"} '))
(/var/www/app/vendor/monolog/monolog/src/Monolog/Logger.php:325)
at Monolog\Logger->addRecord(400, 'The stream or file "/var/www/app/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied', array('exception' => object(UnexpectedValueException)))
(/var/www/app/vendor/monolog/monolog/src/Monolog/Logger.php:543)
at Monolog\Logger->error('The stream or file "/var/www/app/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied', array('exception' => object(UnexpectedValueException)))
(/var/www/app/vendor/laravel/framework/src/Illuminate/Log/Logger.php:174)
at Illuminate\Log\Logger->writeLog('error', 'The stream or file "/var/www/app/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied', array('exception' => object(UnexpectedValueException)))
(/var/www/app/vendor/laravel/framework/src/Illuminate/Log/Logger.php:87)
at Illuminate\Log\Logger->error('The stream or file "/var/www/app/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied', array('exception' => object(UnexpectedValueException)))
(/var/www/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php:547)
at Illuminate\Log\LogManager->error('The stream or file "/var/www/app/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied', array('exception' => object(UnexpectedValueException)))
(/var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php:122)
at Illuminate\Foundation\Exceptions\Handler->report(object(UnexpectedValueException))
(/var/www/app/app/Exceptions/Handler.php:40)
at App\Exceptions\Handler->report(object(UnexpectedValueException))
(/var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:88)
at Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(object(UnexpectedValueException))
 
Okay, I think the issue is how you are referencing services running on the host machine. Localhost does not reference the host machine, it references the container. Looking around on google it looks like there are a few different ways to do this:

(1) Try using the IP 172.17.0.1 (i.e. set the deepstack base url to . This url does resolve for me on Linux, but it did not on windows.

(2) Alternatively, try using the special DNS host.docker.internal according to Networking features in Docker Desktop for Windows . I just tried this on my windows machine and the host name did resolve. Supposedly this works on Mac too. Try setting your base url to .

(3) Try adding the host option to the services in docker-compose so that they share the same network as the host (Option network_mode: host in docker compose file not working as expected). This would be harder to set up I think but it would allow you to use "localhost" or "127.0.0.1" to hit services on the host.

Also note that the Last Watch application does not care how you run Deepstack. It is completely independent, in fact you could use a different AI engine if you wanted to. If deepstack isn't running you won't have any issues starting up the rest of the application, so that's to be expected. The only time you would see errors is when the app attempts to call deepstack and the service is not running at the url specified in the .env file.


Thank you very much.

The first option did not work for me.
The second option ... i am not sure if i can just change the URL to "host.docker.internal" or "gateway.docker.internal" or if i need to install/setup something to get it running. By just using these 2 URLS it does not work for me

The last option i didnt even try :-D


Can somebody confirm any of these options or tell me what i need to setup for the second option?
 
So I had some time tonight to take another look at this. I got the webUI working by installing the project under the first user rather than creating another one as suggested in the tutorial. I think I agree that there must have been a permissions problem before. The Samba share also works and I'm able to save images there. I checked through the mapped drive in windows and the command line in ubuntu that the files are getting to the /home/"username"/aiinput folder. I'm also checked that the file permissions are correct as per your suggestions in post #27.

The issue now is that the images are not being seen in the webUI. I've setup the UI as per the tutorial, but there is no indication that the program is looking in the right folder for the images. How can I check where it's looking?

The laravel.log file doesn't exist, which leads me to believe nothing is wrong with the program.

Thanks so much for the help and the great program. I'm looking forward to finally getting it working.

UPDATE:

I've been able to get over that last hurdle and now the program seems to be running properly. I'll have to monitor over the next few days to fine tune things.

I made a mistake in the trigger url and I can't figure out a way to modify or delete the bad web request automations. Perhaps that's a feature that should be added?

Thanks again guys for all the help and contributing to the community. Much appreciated.
 
Last edited:
Hi Thanks for sharing this project

I am having trouble accessing the webui with the following displayed when going to localhost:8080 using a fresh install of win10 pro and docker desktop 3.1.0


Warning: require(/var/www/app/public/../vendor/autoload.php): failed to open stream: No such file or directory in /var/www/app/public/index.php on line 22

Fatal error
: require(): Failed opening required '/var/www/app/public/../vendor/autoload.php' (include_path='.:/usr/local/lib/php') in /var/www/app/public/index.php on line 22

appreciate any help given
Thanks
 
EDIT: this issue has been fixed

Sorry for asking so many questions, but I'm having a new problem.

BI is setup and sending image captures to the aiinput folder. Lastwatch is not processing the images right away though. It seems to build up 100 or 1000 images and then processes them in a batch. A few my trickle through in between batches, but nothing is getting triggered when the motion event is actually happening.

I've set the time on both VMs to use an ntp server and verified that the time and date are the same. I don't know what else to check. Any ideas?

I'm also using ~70% of 8 CPU cores. seems a bit high.

Thanks.
 
Last edited:
So I had some time tonight to take another look at this. I got the webUI working by installing the project under the first user rather than creating another one as suggested in the tutorial. I think I agree that there must have been a permissions problem before. The Samba share also works and I'm able to save images there. I checked through the mapped drive in windows and the command line in ubuntu that the files are getting to the /home/"username"/aiinput folder. I'm also checked that the file permissions are correct as per your suggestions in post #27.

The issue now is that the images are not being seen in the webUI. I've setup the UI as per the tutorial, but there is no indication that the program is looking in the right folder for the images. How can I check where it's looking?

The laravel.log file doesn't exist, which leads me to believe nothing is wrong with the program.

Thanks so much for the help and the great program. I'm looking forward to finally getting it working.

UPDATE:

I've been able to get over that last hurdle and now the program seems to be running properly. I'll have to monitor over the next few days to fine tune things.

I made a mistake in the trigger url and I can't figure out a way to modify or delete the bad web request automations. Perhaps that's a feature that should be added?

Thanks again guys for all the help and contributing to the community. Much appreciated.

Hey, I'm glad you got it working! What did you do to get the images to display? That was a common problem I faced early on.

Running as the first user (i.e. uid 1000) is the default assumption. I tried to make it clear in the guide that you only need to set up a sudouser if none had previously been created. If you already have a sudouser set up, go ahead and use that one unless you want to run everything as a separate user for some reason.

The missing log file could mean that no errors were logged. If the app is trying to log and it's failing, you would get 500 errors from the web UI.

I agree, deleting/editing automations is on the feature request list. This would be a great first enhancement for anyone interested in contributing. In the mean time, the only way to delete or edit automations is to manually drop them from the database. Otherwise I recommend never making mistakes :)
 
EDIT: this issue has been fixed

Sorry for asking so many questions, but I'm having a new problem.

BI is setup and sending image captures to the aiinput folder. Lastwatch is not processing the images right away though. It seems to build up 100 or 1000 images and then processes them in a batch. A few my trickle through in between batches, but nothing is getting triggered when the motion event is actually happening.

I've set the time on both VMs to use an ntp server and verified that the time and date are the same. I don't know what else to check. Any ideas?

I'm also using ~70% of 8 CPU cores. seems a bit high.

Thanks.

The file watcher seems to be the biggest problem right now, you aren't the first to report performance issues. There is an issue open in github from another user who had a similar issue where it was taking several hours to process new files. I have also confirmed that chokidar is using more CPU than it should, but 70% seems really high (I barely go above 10-15% on 2 cores in Ubuntu).

I really want to replace the file watcher with something better but the right idea hasn't come to me yet. This is a tricky problem to solve in docker across windows and linux. There are solutions that may work better on windows or on linux, but rarely on both.

Try running sudo docker stats from the command prompt to see which container is hogging CPU. Some things you can try to improve the file watcher:

* enable polling in the .env file (restart the containers after changing the setting). Polling might help with getting images processed faster, but probably won't help with CPU usage.

* try starting with a clean watch folder. If the watch folder contains a lot of files, or a deep structure of folders and subfolders, performance will suffer. I have found that when the watch folder is empty, the watcher uses virtually zero resources.
 
Hi Thanks for sharing this project

I am having trouble accessing the webui with the following displayed when going to localhost:8080 using a fresh install of win10 pro and docker desktop 3.1.0


Warning: require(/var/www/app/public/../vendor/autoload.php): failed to open stream: No such file or directory in /var/www/app/public/index.php on line 22

Fatal error
: require(): Failed opening required '/var/www/app/public/../vendor/autoload.php' (include_path='.:/usr/local/lib/php') in /var/www/app/public/index.php on line 22

appreciate any help given
Thanks

Did you install from source or did you download an official release zip? My best guess is that you downloaded the source code by mistake instead of the compiled release. These errors typically happen when you try to run the web app without building/compiling the source code..

Make sure you get the file named last-watch-ai-x.x.x.zip when downloading the release. If you did mean to install from source, make sure you follow the instructions in the readme to build the code.
 
Did you install from source or did you download an official release zip? My best guess is that you downloaded the source code by mistake instead of the compiled release. These errors typically happen when you try to run the web app without building/compiling the source code..

Make sure you get the file named last-watch-ai-x.x.x.zip when downloading the release. If you did mean to install from source, make sure you follow the instructions in the readme to build the code.
Thanks for the reply
yes i was definately downloading the official release i had tried 0.9.0 and 0.8.0 but i have finally got it going, i deleted the container and re run docker compose a number of times with the only change being a similar error (same error but it was a slightly different path and mentioned line 5 instead of 22) then randomly afer going for a drinks break i refreshed the webpage and it started working so fingers crossed
 
Hi kleyplot, I'm using a jetson nano for deepstack. I would test it out on the ARM64 platform. Is there a way to get it going? Thank's!