Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


    Cloudron Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular

    Passing the Healthcheck on custom app

    App Packaging & Development
    3
    18
    517
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • timconsidine
      timconsidine App Dev last edited by timconsidine

      In brief :
      I am attempting to package a custom app which initially is a processor app with no webpage interface. It waits for files in directories under /app/data and processes them.
      So there is nothing to return a 2xxx to the Healthcheck.
      So it never passes and the app never reaches Running status, although it does work to process files as required.

      Question :
      How can I 'frig' a 2xx response?
      I stuck a hello world index.html in app/data/public but seems this is not enough.

      A bit more detail :
      I write various documents like presentations & proposals in Markdown and then process this with pandoc and a bespoke eisvogel.latex layout template for a beautiful PDF (well, in my opinion anyway).
      Problem is I need to replicate this command line setup on every device I work on (2 laptops, 3 desktops, 3 locations, 2 countries) and it's a pain to share this setup as a production environment with others so they can produce their own docs in similar format.
      My plan is to set up a Cloudron app which has the pandoc setup. Then I and others just upload a doc like proposal.md to get a beautiful proposal.pdf.

      I guess the real answer to my question is to build a front-end providing a browser interface for uploading and downloading files. That should return the 2xx response needed. But I can't get my head around how to build that interface at the moment. So was hoping to build the app as 'alpha' without the front-end.
      Any advice to frig the 2xx response temporarily or how to find some example upload/download interface would be most appreciated.

      1 Reply Last reply Reply Quote 1
      • H
        hendrikvl last edited by

        I had the same issue with a custom app I created. My solution was to include a webserver that runs in parallel via supervisord, although my custom app would not require it for its own functioning.
        A sample of what this could look like is in the supervisor demo-app: https://git.cloudron.io/cloudron/tutorial-supervisor-app/
        The webserver in there only returns a static page with status code 200, which is all you need to pass the health-check.

        timconsidine 2 Replies Last reply Reply Quote 2
        • timconsidine
          timconsidine App Dev @hendrikvl last edited by

          @hendrikvl : brilliant thank you 👍
          I know nothing about supervisor.
          But I guess a good opportunity to learn 😊

          1 Reply Last reply Reply Quote 0
          • timconsidine
            timconsidine App Dev @hendrikvl last edited by

            @hendrikvl : great, that works !
            Integrated the tutorial-supervisor app with the custom app.
            It now passes the healthcheck 🍾

            Now need to learn about supervisor and how to build an interface for source file upload and PDF download. I'm just a monkey see, monkey do hacker.

            Thanks again @hendrikvl !

            1 Reply Last reply Reply Quote 1
            • nebulon
              nebulon Staff last edited by

              Yes what @hendrikvl suggested is correct. One reason also why Cloudron apps are essentially required to have something on http(s) is that the app will show up in the dashboard and when someone clicks on the app tile, it should go somewhere meaningful.

              I guess "worker" apps were simply not part of the current design and so far not really much asked for and it looks like even in your case, some rudimentary webinterface is wanted.

              timconsidine 2 Replies Last reply Reply Quote 1
              • timconsidine
                timconsidine App Dev @nebulon last edited by

                @nebulon yes indeed.
                Now I know what to do for basic response, all is cool.
                I'm not a programmer really, just know how to hack about.

                One thought, I'm kinda ok with PHP.
                Is there anything to prevent me installing pandoc into a LAMP app ? It's basically :

                RUN apt-get -qq update && \
                    apt-get -qq -y install wget texlive-latex-base texlive-fonts-recommended && \
                    apt-get -qq -y install texlive-fonts-extra texlive-latex-extra && \
                    apt-get -qq -y install lmodern && \
                    apt-get clean
                
                RUN wget https://github.com/jgm/pandoc/releases/download/${PANDOC_VERSION}/pandoc-${PANDOC_VERSION}-1-amd64.deb && \
                    dpkg -i pandoc* && \
                    rm pandoc* && \
                    apt-get clean
                

                I can do that manually maybe after installing LAMP and then build a web interface in PHP. Vaguely within my skill set !
                Or maybe I should just get modern and learn about nodejs.

                nebulon 1 Reply Last reply Reply Quote 0
                • nebulon
                  nebulon Staff @timconsidine last edited by

                  @timconsidine the LAMP app package would not allow you to run apt-get and install further packages in a persistent manner, however you could essentially fork the LAMP app package and start from there.

                  timconsidine 1 Reply Last reply Reply Quote 1
                  • timconsidine
                    timconsidine App Dev @nebulon last edited by

                    @nebulon thank you

                    1 Reply Last reply Reply Quote 0
                    • timconsidine
                      timconsidine App Dev @nebulon last edited by

                      @nebulon I decided to bite bullet and learn some basic node.js to build a basic web front-end.
                      Works fine on my local machine using node server.js.
                      But hangs when I build and install the image to Cloudron.
                      Obviously down to me to debug what it doesn't like.
                      I'm looking through some other Cloudron apps on https://git.cloudron.io/explore for clues and stuff to borrow.
                      But a lot there.

                      1. Wondering if anyone has a suggestion for Cloudron app which has a more sophisticated, but not too sophisticated, example!!

                      2. My basic example uses :
                        // var url = require('url');
                        // var fs = require('fs');
                        // var formidable = require('formidable');
                        They're listed in package.json or package-lock.json.
                        Might those be causing a problem with the Cloudron install?

                      nebulon 1 Reply Last reply Reply Quote 1
                      • nebulon
                        nebulon Staff @timconsidine last edited by

                        @timconsidine might be easier, if you push your current code to some public repository or so, to better guide you.

                        timconsidine 2 Replies Last reply Reply Quote 1
                        • timconsidine
                          timconsidine App Dev @nebulon last edited by

                          @nebulon will do, good idea.

                          nebulon 1 Reply Last reply Reply Quote 0
                          • nebulon
                            nebulon Staff @timconsidine last edited by

                            @timconsidine may not be required, but the expressjs framework is usually a solid option to be used. Cloudron itself and also surfer and the likes use that.

                            timconsidine 1 Reply Last reply Reply Quote 1
                            • timconsidine
                              timconsidine App Dev @nebulon last edited by timconsidine

                              @nebulon said in Passing the Healthcheck on custom app:

                              the expressjs framework is usually a solid option to be used

                              Express looks good but I will learn this another day. I had already gone down a "manual code" direction, and didn't want to re-do it. I will probably produce a new version with Express later.

                              1 Reply Last reply Reply Quote 0
                              • timconsidine
                                timconsidine App Dev @nebulon last edited by

                                @nebulon said in Passing the Healthcheck on custom app:

                                if you push your current code to some public repository

                                I have solved the problems I was encountering. Phew.
                                Now in a basic working state. Not pretty but functional.

                                I will share in case it can be useful to others or there is advice on how to do it better.

                                I tried to create a project on https://git.cloudron.io to upload
                                But I got invalid namespace
                                Is creating projects on git.cloudron.io restricted ?

                                timconsidine nebulon 2 Replies Last reply Reply Quote 0
                                • timconsidine
                                  timconsidine App Dev @timconsidine last edited by timconsidine

                                  @timconsidine I have created a public repository at https://git.firstoption.com/timconsidine/Cloudron-Pandoc-PDF-Builder

                                  https://git.cloudron.io/timconsidine/cloudron-pandoc-pdf-builder/

                                  Feel free to use.
                                  Let me know any errors or issues.

                                  I will look into making it a node express project later.

                                  timconsidine 1 Reply Last reply Reply Quote 1
                                  • timconsidine
                                    timconsidine App Dev @timconsidine last edited by timconsidine

                                    @timconsidine oooops, appears to be an issue when downloading.
                                    Will fix that and advise
                                    EDIT : there appears to be a problem downloading on first run. But it works on subsequent runs. For now, just press back in browser, return home, and run again if error screen appears. Will investigate further, but basically working with this work-around. May be an issue if processing a large document, may need some some onFinish type statements somewhere.

                                    1 Reply Last reply Reply Quote 0
                                    • nebulon
                                      nebulon Staff @timconsidine last edited by

                                      @timconsidine said in Passing the Healthcheck on custom app:

                                      Is creating projects on git.cloudron.io restricted ?

                                      yes by default we limit new accounts to avoid spam. I have granted your gitlab account now more privileges to create projects.

                                      timconsidine 1 Reply Last reply Reply Quote 1
                                      • timconsidine
                                        timconsidine App Dev @nebulon last edited by timconsidine

                                        @nebulon thank you, will move the repo over

                                        1 Reply Last reply Reply Quote 0
                                        • First post
                                          Last post
                                        Powered by NodeBB