AnthonyMusgrove / Emby-ScripterX

Run custom external application or script (batch/bash/powershell/php/python/node.js/custom) on various events within the Emby Server.
https://emby-scripterx.com
76 stars 6 forks source link

Event scripts don't execute #28

Closed Slugger closed 4 years ago

Slugger commented 4 years ago

Describe the bug Fresh install on Linux. Setup one event to test: onScheduledTask. Trigger the scheduled task from Emby dashboard and nothing happens.

To Reproduce Steps to reproduce the behavior:

  1. Install ScripterX on Linux
  2. Configure onScheduledTask event
  3. Go to Scheduled Tasks in Emby dashboard
  4. Manually fire ScripterX task
  5. Task reports as "Failed"
  6. Stacktrace from logs pasted below

Expected behavior The configured script to execute when the scheduled task is triggered I also tried setting up other events (Auth failed, etc.) and triggered those events in Emby but the script was never triggered by the plugin.

Screenshots image image

Desktop (please complete the following information):

Smartphone (please complete the following information): n/a

Additional context

2020-06-07 09:10:01.781 Error TaskManager: Error in event handler
    *** Error Report ***
    Version: 4.4.2.0
    Command line: /app/emby/EmbyServer.dll -programdata /config -ffdetect /app/emby/ffdetect -ffmpeg /app/emby/ffmpeg -ffprobe /app/emby/ffprobe -restartexitcode 3
    Operating system: Unix 4.19.0.9
    64-Bit OS: True
    64-Bit Process: True
    User Interactive: True
    Runtime: file:///app/emby/System.Private.CoreLib.dll
    System.Environment.Version: 3.1.2
    Processor count: 4
    Program data path: /config
    Application directory: /app/emby
    System.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object.
       at EmbyScripterX.EventManagers.ScripterXTaskManager._taskManager_TaskExecuting(Object sender, GenericEventArgs`1 e)
       at MediaBrowser.Common.Events.EventHelper.FireEventIfNotNull[T](EventHandler`1 handler, Object sender, T args, ILogger logger)
    Source: EmbyScripterX
    TargetSite: Void _taskManager_TaskExecuting(System.Object, MediaBrowser.Model.Events.GenericEventArgs`1[MediaBrowser.Model.Tasks.IScheduledTaskWorker])

2020-06-07 09:10:01.782 Error TaskManager: Error
    *** Error Report ***
    Version: 4.4.2.0
    Command line: /app/emby/EmbyServer.dll -programdata /config -ffdetect /app/emby/ffdetect -ffmpeg /app/emby/ffmpeg -ffprobe /app/emby/ffprobe -restartexitcode 3
    Operating system: Unix 4.19.0.9
    64-Bit OS: True
    64-Bit Process: True
    User Interactive: True
    Runtime: file:///app/emby/System.Private.CoreLib.dll
    System.Environment.Version: 3.1.2
    Processor count: 4
    Program data path: /config
    Application directory: /app/emby
    System.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object.
       at EmbyScripterX.ScripterXScheduledTaskController.ProcessScheduledTask()
       at EmbyScripterX.ScripterXScheduledTaskController.Execute(CancellationToken cancellationToken, IProgress`1 progress)
       at Emby.Server.Implementations.ScheduledTasks.ScheduledTaskWorker.ExecuteInternal(TaskOptions options)
    Source: EmbyScripterX
    TargetSite: System.Threading.Tasks.Task`1[System.Int32] ProcessScheduledTask()

2020-06-07 09:10:01.782 Debug TaskManager: Emby ScripterX Scheduled Task Failed after 0 minute(s) and 0 seconds
2020-06-07 09:10:01.814 Error TaskManager: Error in event handler
    *** Error Report ***
    Version: 4.4.2.0
    Command line: /app/emby/EmbyServer.dll -programdata /config -ffdetect /app/emby/ffdetect -ffmpeg /app/emby/ffmpeg -ffprobe /app/emby/ffprobe -restartexitcode 3
    Operating system: Unix 4.19.0.9
    64-Bit OS: True
    64-Bit Process: True
    User Interactive: True
    Runtime: file:///app/emby/System.Private.CoreLib.dll
    System.Environment.Version: 3.1.2
    Processor count: 4
    Program data path: /config
    Application directory: /app/emby
    System.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object.
       at EmbyScripterX.EventManagers.ScripterXTaskManager._taskManager_TaskCompleted(Object sender, TaskCompletionEventArgs e)
       at MediaBrowser.Common.Events.EventHelper.FireEventIfNotNull[T](EventHandler`1 handler, Object sender, T args, ILogger logger)
    Source: EmbyScripterX
    TargetSite: Void _taskManager_TaskCompleted(System.Object, MediaBrowser.Model.Tasks.TaskCompletionEventArgs)
AnthonyMusgrove commented 4 years ago

Thank you for logging this issue, I'll look into it right now.

AnthonyMusgrove commented 4 years ago

I have tested baseline with windows, and scheduled task operations work, ie Scheduled Task Run on MediusDev2 - embyver: 4.4.3.0 - scripterxver: 3.0.3.1

I'm now downloading a fresh copy of ubuntu to install in a VM to test fresh environment, I just need to catch what exactly was null at that point, because the exception is thrown because some value is null;; I'll find it though, without a doubt :)

AnthonyMusgrove commented 4 years ago

So far on a fresh ubuntu install I am not able to replicate the issue, which is very unfortunate, but I want to figure this one out for you.

Which operating system and version are you using mate?

Ubuntu latest:

cripterx@ubuntu:~/Emby/Scripts$ tail scheduledtask.log

onScheduled Task called - [Server Name: ubuntu] [Server Version: 4.4.3.0] [ScripterX Version: 3.0.3.1] scripterx@ubuntu:~/Emby/Scripts$

Slugger commented 4 years ago

Running Emby in a docker on Debian 10. Using this docker image: https://hub.docker.com/r/linuxserver/emby

AnthonyMusgrove commented 4 years ago

Thank you @Slugger I'll see if I can replicate it now.

AnthonyMusgrove commented 4 years ago

Hi mate, so I have installed a fresh copy of Debian 10 in a virtual machine. I've installed docker, pulled the image you specified, created a container and ran it.

I've installed ScripterX and configured authFailed and ScheduledTask, and all are working as per:

anthony@embydocker:/media/scripts$ ls authfail.log auth_fail.sh scheduledtask.log scheduledtask.sh anthony@embydocker:/media/scripts$ pwd /home/anthony/media/scripts

The docker create command I used:

docker create \ --name=emby \ -e PUID=1000 \ -e PGID=1000 \ -e TZ=Australia/Sydney \ -e UMASK_SET=022 #optional \ -p 192.168.29.132:8096:8096 \ -p 192.168.29.132:8920:8920 #optional \ -v /home/anthony/media:/config \ -v /home/anthony/media/tv:/data/tvshows \ -v /home/anthony/media/movies:/data/movies \ -v /home/anthony/media/transcode:/transcode #optional \ -v /home/anthony/media/scripts:/data/scripts \ -v /opt/vc/lib:/opt/vc/lib #optional \ --restart unless-stopped \ linuxserver/emby

The configuration for onAuthenticationFailed:

image

The configuration for onScheduledTask:

image

The scripts:

auth_fail.sh: echo Authentication Failed: Device: $1 - Username: $2 >> /data/scripts/authfail.log

scheduledtask.sh: echo Scheduled Task Called: Server Name: $1 - >> /data/scripts/scheduledtask.log

Outputs respectively (the contents of the .log files):

authfail.log: Authentication Failed: Device: Firefox - Username: anthony

scheduledtask.log: Scheduled Task Called: Server Name: sxdocker -

AnthonyMusgrove commented 4 years ago

edit: I also tried run with bash too, instead of /bin/bash and it still worked.

Slugger commented 4 years ago

I'm not running the latest docker image so I guess I'll try upgrading to that and see if that fixes it and will report back.

AnthonyMusgrove commented 4 years ago

No problems mate, thank you for that :)

Slugger commented 4 years ago

Upgraded to the latest emby docker image and all seems to be working good now. I was running 4.4.2 so not like it was that old a version, but I guess just old enough. Thanks.