Announcement

Collapse
No announcement yet.

When developing a plugin, where should I put it in the Docker container?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    When developing a plugin, where should I put it in the Docker container?

    > http://www.mysqueezebox.com/update/?...=1&os=debamd64
    >
    > Currently this is returning:
    > https://downloads.slimdevices.com/Lo....2.0_amd64.deb
    >
    > Shouldn't this be something based on 8.2.1?


    No, your query would return the latest release version. Which is 8.2.0.
    8.2.1 is a nightly build. Stable but can change at any time. You'd get
    the latest 8.2.1 if you replaced 8.0.0 in your query with 8.2.1
    (whenever a new build was available).

    #2
    When developing a plugin, where should I put it in the Docker container?

    Hi,

    Trying to pick up work on my SimpleLibraryViews plugin using the Docker container to develop on.

    I've found that if I put it in /config/cache/InstalledPlugins/Plugins then it gets deleted unless LMS thinks it should be installed.

    There is another directory in /config/cache/Plugins, but if I put the plugin there, it doesn't seem to be found correctly at startup:

    [quote]
    Can't locate Plugins/SimpleLibraryViews/Plugin.pm in @INC (you may need to install the Plugins::SimpleLibraryViews::Plugin module) (@INC contains: /config/cache/InstalledPlugins /lms/CPAN/arch/5.32/x86_64-linux-thread-multi /lms/CPAN/arch/5.32/x86_64-linux-thread-multi/auto /lms/CPAN/arch/5.32.1/x86_64-linux-gnu-thread-multi /lms/CPAN/arch/5.32.1/x86_64-linux-gnu-thread-multi/auto /lms/CPAN/arch/5.32/x86_64-linux-gnu-thread-multi /lms/CPAN/arch/5.32/x86_64-linux-gnu-thread-multi/auto /lms/CPAN/arch/x86_64-linux-gnu-thread-multi /lms/CPAN/arch/5.32 /lms/lib /lms/CPAN /lms /lms /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.32.1 /usr/local/share/perl/5.32.1 /usr/lib/x86_64-linux-gnu/perl5/5.32 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.32 /usr/share/perl/5.32 /usr/local/lib/site_perl /config/cache) at (eval 916) line 1.
    [22-05-16 23:16:15.6871] Slim::Utils::PluginManager::load (323) Error: Couldn't load Plugins::SimpleLibraryViews::Plugin
    [quote]

    What's the easiest way to work on developing a plugin in the Docker container?

    Thanks

    Andy

    Comment


      #3
      When developing a plugin,where should I put it in the Docker container?

      > There is another directory in /config/cache/Plugins, but if I put the
      > plugin there, it doesn't seem to be found correctly at startup:


      Where exactly is your Plugin.pm stored?
      Michael

      "It doesn't work - what shall I do?" - "Please check your server.log and/or scanner.log file!"
      (LMS: Settings/Information)

      Comment


        #4
        Hi Michael,

        Originally posted by mherger View Post
        Where exactly is your Plugin.pm stored?
        [email protected]:/config/cache/Plugins/SimpleLibraryViews# pwd
        /config/cache/Plugins/SimpleLibraryViews
        [email protected]:/config/cache/Plugins/SimpleLibraryViews# ls -l
        total 24
        drwxr-xr-x 3 squeezeboxserver nogroup 4096 May 16 23:15 HTML
        -rwxr-xr-x 1 squeezeboxserver nogroup 5791 May 16 23:15 Plugin.pm
        -rwxr-xr-x 1 squeezeboxserver nogroup 1917 May 16 23:15 Settings.pm
        -rwxr-xr-x 1 squeezeboxserver nogroup 701 May 16 23:15 install.xml
        -rwxr-xr-x 1 squeezeboxserver nogroup 491 May 16 23:15 strings.txt

        Comment


          #5
          Ok, I think it might have been because it was still looking for the 'official' plugin. I've cleaned out some config and the like, and am now getting Perl errors regarding syntax issues in SimpleLibraryViews (which is probably due to the changes I've made).

          Will report back if I need any further assistance! Thanks.

          Andy

          Comment


            #6
            Here is how I do it (which I know Michael does not endorse) but it would have avoided the problem you have hit.

            I make a genuine repo XML file and host it somewhere private that LMS can access (and I sometimes give that URL to beta testers).
            Then I make a real plugin (a skeleton is enough) and install it using the Settings/Plugin mechanism via the custom repo.

            Then I work on the code and simply transfer it to the installation location without updating the install.xml (my LMS is running on a Raspberry Pi but my development is on Windows).
            Then a simple stop/start of LMS (sometimes needs to be started twice because it quits without an error message) and the new code is up and running.

            Eventually I decide that my updates are worth calling a beta release so I update the install.xml version number and the repo xml version number, file pointer & checksum and perform a real update with LMS. This also helps me check that the packaging is right which is useful for when preparing a real release.

            For version numbering I put a letter after the numbers ... so it goes
            1, 2a, 2b, 2c, 2, 3a, 3b, 3
            with 1, 2 and 3 being the official releases and the ones with letters at the end as the beta of what will become the official release.

            Of course, a proper change control system and automated builds would be much more professional - but I have not invested the time to do that.
            Paul Webster
            Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
            and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin

            Comment


              #7
              Ok, got the new code up and running, but for some reason the scanner doesn't seem to be calling my plugin's 'createLibrary' function. It is being called when the server starts, but the plugin exits at that point as it's expecting to be called by the scanner:

              return if ! main::SCANNER;
              If I do a scan on my 'real' LMS, I get:

              [quote]
              Discovering files/directories: /var/spool/music/tagged (6507 of 6507) Complete 00:00:06
              Removing deleted files: /var/spool/music/tagged (66 of 66) Complete 00:00:01
              Scanning new music files: /var/spool/music/tagged (1 of 1) Complete 00:00:00
              Scanning changed files: /var/spool/music/tagged (8 of 8) Complete 00:00:03
              Scanning new media files: /var/spool/music/tagged (149 of 149) Complete 00:00:02
              Discovering playlists: /var/spool/music/tagged/playlists (32 of 32) Complete 00:00:00
              Scanning new playlists: /var/spool/music/tagged/playlists (31 of 31) Complete 00:00:12
              Create Library Views (5 of 5) Complete 00:00:11
              Find Updated Coverart Files (336 of 336) Complete 00:00:01
              Pre-caching Artwork (8 of 8) Complete 00:00:03
              Database Optimize (2 of 2) Complete 00:00:03
              The server has finished scanning your media library.
              Total Time: 00:00:42 (Tuesday, May 17, 2022 / 10:12 am)
              [quote]

              (note the 'Create Library Views' line)

              However, on this development LMS all I get is:

              Discovering files/directories: /var/spool/music/tagged/FLAC/J (131 of 131) Complete 00:00:00
              Scanning new music files: /var/spool/music/tagged/FLAC/J (66 of 66) Complete 00:00:01
              Building full text index (7 of 7) Complete 00:00:00
              Pre-caching Artwork (34 of 34) Complete 00:00:01
              Database Optimize (2 of 2) Complete 00:00:00
              The server has finished scanning your media library.
              Total Time: 00:00:02 (Tuesday, May 17, 2022 / 10:35 AM)
              Any suggestions?

              Thanks

              Andy

              Comment


                #8
                A bit more digging as I refresh my memory of how this plugin works! All of this is running in the latest Docker container.

                I have the following code in the plugin:

                my $newID = Slim::Music::VirtualLibraries->registerLibrary( {
                id => $library,
                name => "SimpleLibraryViews $library",
                scannerCB => sub {
                my $libraryId = shift;
                main:EBUGLOG && $log->is_debug && $log->debug("Scanner callback for libraryId: '$libraryId'");
                main:EBUGLOG && $log->is_debug && $log->debug("Scanner callback for library: '$library'");

                createLibrary($libraryId, $library);

                main:EBUGLOG && $log->is_debug && $log->debug("Scanner callback called createLibrary");
                }
                } );

                $log->info("Registered library $newID");
                Whenever I make a settings change that creates a new library in my plugin, I see the 'Registered library xxxx' line in the log, with what seems to be a valid ID (e.g. f46a55b9).

                When the server starts, I see the 'Scanner callback...' log entries, and an entry from within createLibrary that shows it was called outside of the scanner. However, when I run a scan (clear all and rescan at the moment) I don't see any of these entries.

                The updated code is here:



                Any suggestions?

                Andy
                Last edited by adhawkins; 2022-05-17, 12:35. Reason: Disable smilies

                Comment


                  #9
                  When developing a plugin,where should I put it in the Docker container?

                  > A bit more digging as I refresh my memory of how this plugin works! All
                  > of this is running in the latest Docker container.


                  Do you register an importer module?

                  Michael

                  "It doesn't work - what shall I do?" - "Please check your server.log and/or scanner.log file!"
                  (LMS: Settings/Information)

                  Comment


                    #10
                    Originally posted by mherger View Post
                    Do you register an importer module?
                    Not as far as I'm aware. Is that something new?

                    Andy

                    Comment


                      #11
                      Ah, just checked the 'install.xml' file:

                      <importmodule>Plugins::SimpleLibraryViews::Plugi n</importmodule>
                      Will that be picked up just by dropping the module source into /config/cache/Plugins? Or does the server need to 'install' the module to pick that up?

                      Andy
                      Last edited by adhawkins; 2022-05-17, 15:02.

                      Comment


                        #12
                        When developing a plugin,where should I put it in the Docker container?

                        >> <importmodule>Plugins::SimpleLibraryViews::Plugi n</importmodule>
                        >
                        > Will that be picked up just by dropping the module source into
                        > /config/cache/Plugins? Or does the server need to 'install' the module
                        > to pick that up?


                        This line will cause the scanner to call
                        Plugins::SimpleLibraryViews::Plugin->initPlugin(). But it will NOT
                        automatically create a scan task. Therefore you should call
                        Slim::Music::Import->addImporter() to tell the scanner that you have an
                        importer, what type it is (file importer, post processing etc.), and how
                        to call it.

                        See eg.

                        Michael

                        "It doesn't work - what shall I do?" - "Please check your server.log and/or scanner.log file!"
                        (LMS: Settings/Information)

                        Comment


                          #13
                          What I don't understand is why the existing plugin works just fine on my 'real' LMS (which is up-to-date I believe).

                          Doesn't the 'scannerCB' parameter of 'Slim::Music::VirtualLibraries->registerLibrary' handle that (causing the library to be updated during a scan)?

                          Andy

                          Comment


                            #14
                            When developing a plugin,where should I put it in the Docker container?

                            > What I don't understand is why the existing plugin works just fine on my
                            > 'real' LMS (which is up-to-date I believe).


                            Ah, ok, then there must be something else going on.

                            What's the difference between the two installations again? No code change?
                            Michael

                            "It doesn't work - what shall I do?" - "Please check your server.log and/or scanner.log file!"
                            (LMS: Settings/Information)

                            Comment


                              #15
                              Installation 1 is a Debian VM with LMS installed from the Debian package. It has my plugin installed 'correctly' by ticking the box in the Plugins section to get it from the repo.

                              Installation 2 is a Docker install. My (newly modified) plugin is copied into /lms/cache/Plugins. I pasted the file layout above. I've made changes to the plugin, but not (I believe) to the 'core' code, only the code that decides whether a particular track is part of the library or not. I'll try reverting this to the released code but copied in to LMS in the same way.

                              Is the manual copy method likely to cause any difference in the way the plugin registers itself?

                              I should probably add that if I allow the scan to happen at server startup, then the code seems to work as expected. However, this is inhibited as other it delays the startup of the server considerably.

                              All code is available at https://github.com/adhawkins/SimpleLibraryViews

                              The 'master' branch is the released code which is working on installation 1. The contents of the 'recurse' branch is the code I'm currently working on. Any chance you could find time to take a look at the code? It hasn't changed much since what is released, so unless I've done something stupid it should work the same way.

                              Andy

                              Comment

                              Working...
                              X