Announcement

Collapse
No announcement yet.

Miva Merchant licencing of .mvc files + running in fastcgi

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

    Miva Merchant licencing of .mvc files + running in fastcgi

    (it seems that my last account on the forum is no longer accessible, password reset kept failing... sorry for the second one).

    So I have a working implementation of using docker to host a local Miva merchant. I'd like to publish the containers to github, so everyone could have a starting point where they could just clone/fork the repo and get started with local development of modules/templates/etc. I was wondering if it is within the licensing agreement to publish the compiled mvc files in the wwwroot directory as part of the repository? I know I can't publish my key, but I was going to start off with a blank database and, as part of the instructions, have the user put in their own key.

    My second question... While the containers are blazing fast* already, I currently have the web container using fcgiwrap on nginx to proxy into the normal CGI miva engine (no Apache whatsoever). This is because nginx does not support running normal CGI applications. I noticed that in the downloadable distribution there _is_ a fastcgi version of the binaries, but there is no documentation on them, and when I run them there is no output indicating what flags that I have to pass in.

    Is there any place with documentation of how I could configure my dockerized nginx server and the fastcgi build of empresa? Fcgiwrap works great, but it's just one more thing running that needs to be configured.

    Thanks!
    Nelson

    * When running completely in a Linux VM without mounting the source directory to Windows; this is an issue with Docker, not Miva. You can still mount the directories from the Linux host to Docker, so you just have to run your editor in the VM. Not a big deal since I use VSCode.

    #2
    Here are some code snippets that hopefully will help. We don't have docs written for the FastCGI version yet. :-(
    Code:
    server {
                    listen          80;
                    server_name     127.0.0.1;
                    error_log       /var/log/nginx/error.log;
    
                    location / {
                            root    /var/www/html;
                    }
    
                    location ~ \.mvc$ {
                            fastcgi_read_timeout    300;
                            fastcgi_pass            127.0.0.1:8000;
                            fastcgi_param           MvCONFIG_LIBRARY /path/to/config/3x/3x.so;
                            include                 fastcgi_params;
                    }
            }
    fastcgi_params file:
    Code:
     fastcgi_param PATH_INFO $fastcgi_script_name;
    URI management:
    Code:
     
     location / {     root	/var/www/html;     try_files $uri /mm5/uri.mvc$is_args$args; }
    Last edited by ILoveHostasaurus; 03-15-18, 02:55 PM.
    David Hubbard
    CIO
    Miva
    [email protected]
    http://www.miva.com

    Comment


      #3
      Oops, my code post got butchered. Trying to figure out what vbulletin magic I need to use to have it retain its formatting.
      David Hubbard
      CIO
      Miva
      [email protected]
      http://www.miva.com

      Comment


        #4
        Originally posted by ILoveHostasaurus View Post
        Here are some code snippets that hopefully will help. We don't have docs written for the FastCGI version yet. :-(

        Code:
        server { listen 80; server_name 127.0.0.1; error_log /var/log/nginx/error.log; location / { root /var/www/html; } location ~ \.mvc$ { fastcgi_read_timeout 300; fastcgi_pass 127.0.0.1:8000; fastcgi_param MvCONFIG_LIBRARY /path/to/config/3x/3x.so; include fastcgi_params; } }
        fastcgi_params file:

        Code:
         fastcgi_param PATH_INFO $fastcgi_script_name;
        URI management:
        Code:
        location / { root /var/www/html; try_files $uri /mm5/uri.mvc$is_args$args; }
        Thanks for the reply!

        What is running on port 8000? Fastcgi has to connect to a service that is listening already, it won't start a process for me... if I run the fastcgi mivavm, does it spool up a server listening in on port 8000? In my docker container I'm using supervisor to run my PHP-FPM, nginx and fcgiwrap instances. What flags do I need to pass into the fastcgi mivavm from supervisor to get it to spool up on startup?

        Comment


          #5
          Originally posted by ILoveHostasaurus View Post
          Oops, my code post got butchered. Trying to figure out what vbulletin magic I need to use to have it retain its formatting.
          Copy-paste to something like sublime and re-setting \r\n and \n works for me normally, not always though :(

          Comment


            #6
            Originally posted by NLaQuet View Post

            Thanks for the reply!

            What is running on port 8000? Fastcgi has to connect to a service that is listening already, it won't start a process for me... if I run the fastcgi mivavm, does it spool up a server listening in on port 8000? In my docker container I'm using supervisor to run my PHP-FPM, nginx and fcgiwrap instances. What flags do I need to pass into the fastcgi mivavm from supervisor to get it to spool up on startup?
            Finally got it to post. Had to click the A for advanced editor, and click the code button, AND change the font to fixed width; probably something weird we have going on with the forum code. Spawning it is typically personal preference, and the port too of course; spawn-fcgi from lighttpd is popular, for that you'd do something like:

            Code:
            spawn-fcgi -p 8000 -n -- /path/to/mivavm_fastcgi/bin/mivavm_fastcgi &
            Really whatever you prefer for the system in question to daemonize and monitor it. Could use daemontools + tcpserver from ucspi-tcp too, etc.
            David Hubbard
            CIO
            Miva
            [email protected]
            http://www.miva.com

            Comment


              #7
              Originally posted by ILoveHostasaurus View Post

              Finally got it to post. Had to click the A for advanced editor, and click the code button, AND change the font to fixed width; probably something weird we have going on with the forum code. Spawning it is typically personal preference, and the port too of course; spawn-fcgi from lighttpd is popular, for that you'd do something like:

              Code:
              spawn-fcgi -p 8000 -n -- /path/to/mivavm_fastcgi/bin/mivavm_fastcgi &
              Really whatever you prefer for the system in question to daemonize and monitor it. Could use daemontools + tcpserver from ucspi-tcp too, etc.
              Hm, I guess I misunderstood something about the nature of Miva's implementation of fastcgi. So if I'm understanding correctly, using spawn-fcgi will spawn multiple mivavm processes, and each process will stay alive between requests? Or will it just spawn a single mivavm that stays alive between requests? Currently I have fcgiwrap setup to spawn multiple child processes, and per request, one of the child processes will load up mivavm, process the request, and send the returned data back. I'm also able to do this over a linux socket instead of http.

              I guess I assumed Miva's implementation of fastcgi would be akin to php-fpm or even something like spawning (and load balancing) node processes.

              Comment


                #8
                Ah, sorry, the FastCGI Empresa behaves like normal CGI Empresa in that it's single threaded, doesn't spawn copies of itself, and handles one request at a time. So if you were using something like spawn-fcgi or similar, you'd give it a command line argument (-t in this case) to set the number of processes you want. Some of these process spawners may let you get into minimum number of processes, along with maximum, force kill after X number of requests as a precaution, etc.

                How the whole setup will behave when your simultaneous requests exceed the thread limit will depend on both the web server and the process spawner. For example, if using nginx and spawn-fcgi, if you had a 20 thread limit and the 21st request comes in while 20 are active, spawn-fcgi will accept the FastCGI connection at a tcp level, but will hang waiting for a process to poll for requests before connecting it. This keeps nginx happy, up to the keepalive timeout, or fastcgi read timeout, whichever is lowest, and as processes complete their work, they'll call a fastcgi accept function to accept new requests. At that point, the 21st request gets connected and processed. This would be an ideal scenario, where you've successfully protected the system from memory exhaustion due to traffic bursts spawning hundreds or thousands of Empresa's, but you of course also need to find a thread limit that makes sense for the site and server in question; i.e. if the site has any code that blocks, you may want to go to a thread count some amount higher than the server's cpu core count, etc. or you'll be creating artificial delay handling web traffic.
                David Hubbard
                CIO
                Miva
                [email protected]
                http://www.miva.com

                Comment

                Working...
                X