2

I have created a jps file using documentation https://docs.jelastic.com/application-manifest.

But there is no clear documentation to use PostgreSQL.

Jelastic JPS Node:

{
    "nodeType": "postgres9",
    "restart": false,
    "database": {
        "name": "xxxx",
        "user": "xxx",
        "dump": "xxx.sql"
    }
}

Error while configuring environment,

"data": {
    "result": 11005,
    "source": "marketplace",
    "error": "database query error: java.sql.SQLNonTransientConnectionException: Could not connect to address=(host=10.101.3.225)(port=3306)(type=master) : Connection refused (Connection refused)"
}

I have provided whole JPS file content here. In this, i got error when importing database and others are working fine in configs object.

{
    "jpsVersion": "0.1",
    "jpsType": "install",
    "application": {
        "id": "xxx",
        "name": "xxx",
        "version": "0.0.1",
        "logo": "http://example.com/img/logo.png",
        "type": "php",
        "homepage": "http://example.com/",
        "description": {
            "en": "xxx"
        },
        "env": {
            "topology": {
                "ha": false,
                "engine": "php7.2",
                "ssl": false,
                "nodes": [
                    {
                        "extip": false,
                        "count": 1,
                        "cloudlets": 16,
                        "nodeType": "nginxphp"
                    },
                    {
                        "extip": false,
                        "count": 1,
                        "cloudlets": 16,
                        "nodeType": "postgres9"
                    }
                ]
            },
            "upload": [
                {
                   "nodeType": "nginxphp",
                   "sourcePath": "https://example.com/xxx.conf",
                   "destPath": "${SERVER_CONF_D}/xxx.conf"
                }
            ],
            "deployments": [
                {
                    "archive": "https://example.com/xxx.zip",
                    "name": "xxx.zip",
                    "context": "ROOT"
                }
            ],
            "configs": [
                {
                    "nodeType": "nginxphp",
                    "restart": true,
                    "path": "${SERVER_CONF_D}/xxx.conf",
                    "replacements": [
                        {
                           "pattern":"/usr/share/nginx/html",
                           "replacement":"${SERVER_WEBROOT}"
                        }
                    ]
                },
                {
                    "nodeType": "postgres9",
                    "restart": false,
                    "database": {
                        "name": "xxx",
                        "user": "xxx",
                        "dump": "https://example.com/xxx.sql"
                    }
                }, {
                    "restart": false,
                    "nodeType": "nginxphp",
                    "path": "${SERVER_WEBROOT}/ROOT/server/php/config.inc.php",
                    "replacements": [{
                            "replacement": "${nodes.postgres9.address}",
                            "pattern": "localhost"
                        }, {
                            "replacement": "${nodes.postgres9.database.password}",
                            "pattern": "xxx"
                        }
                    ]
                }
            ]
        },
        "success": {
            "text": "Installation completed. username: admin and password: xxx"
        }
    }
}
Virtuozzo
  • 1,993
  • 1
  • 10
  • 13
John
  • 23
  • 4
  • "Connection refused" can be related to some kind of network issues. Also, please use this link https://docs.cloudscripting.com/ as a guide for the JPS practice. – Virtuozzo Nov 06 '18 at 15:38
  • @Jelastic post 3306 is wrong port to try to connect to postgres, so it does not look like a network issue. – Damien - Layershift Nov 07 '18 at 10:07
  • @Damien-Layershift Yes. Its trying to connect in wrong port but i have not mentioned the port. Is there any option to provide port in JPS? – John Nov 09 '18 at 04:40
  • @Jelastic I have also referred docs.cloudscripting.com site but there is no references or examples for PostgreSQL. Just mentioned as postgres9/postgres8. I have mentioned that also but its choosing wrong port. – John Nov 09 '18 at 04:58
  • Did you also check the [placeholders](https://docs.jelastic.com/packaging-standard-placeholders) article for your case? – Virtuozzo Nov 10 '18 at 11:07
  • Yes. Already I have checked that document but there is no option to mention port in database object. ``` "database": { "name": "xxxx", "user": "xxx", "dump": "xxx.sql" } ``` – John Nov 12 '18 at 07:27
  • Also i have provided whole JPS content in description. – John Nov 12 '18 at 07:36
  • http://docs.cloudscripting.com/creating-manifest/actions/#preparesqldatabase please find a Note: The action is executed only for mysql5, mariadb, and mariadb10 containers. – Virtuozzo Nov 16 '18 at 09:54
  • you can use the following workaround in the case with Postgres: onInstall: cmd [sqldb]: | PGPASSWORD=${nodes.sqldb.password}; export PGPASSWORD; psql=`which psql` $psql postgres webadmin -c "CREATE DATABASE Jelastic" – Virtuozzo Nov 16 '18 at 09:56

1 Answers1

1

Since Actions are disabled for the Postgres so far (The action is executed only for mysql5, mariadb, and mariadb10 containers) we've improved your manifest based on the recent updates. Yaml was used because it's more clear for reading and understanding:

jpsVersion: 0.1
jpsType: install
name: xxx
version: 0.0.1
logo: http://example.com/img/logo.png
engine: php7.2
nodes:
  - cloudlets: 16
    nodeType: nginxphp
  - cloudlets: 16
    nodeType: postgres9
onInstall:
  - upload [nginxphp]:
      sourcePath: https://example.com/xxx.conf
      destPath: ${SERVER_CONF_D}/xxx.conf
  - deploy:
      archive: https://example.com/xxx.zip
      name: xxx.zip
      context: ROOT
  - replaceInFile [nginxphp]:
      path: ${SERVER_CONF_D}/xxx.conf
      replacements:
      - pattern: /usr/share/nginx/html
        replacement: ${SERVER_WEBROOT}
  - restartNodes [nginxphp]
  - replaceInFile [nginxphp]:
      path: ${SERVER_WEBROOT}/ROOT/server/php/config.inc.php
      replacements:
      - pattern: localhost
        replacement: ${nodes.postgres9.address}
      - pattern: xxx
        replacement: ${nodes.postgres9.password}
  - cmd [postgres9]: printf "PGPASSWORD=${nodes.postgres9.password};\nexport PGPASSWORD;\npsql postgres webadmin -c \"CREATE DATABASE Jelastic;\"\n" > /tmp/createDb
  - cmd [postgres9]: chmod +x /tmp/createDb && /tmp/createDb
success: Installation completed. username admin and password xxx

Please note, that you can debug every action in the /console tab

Virtuozzo
  • 1,993
  • 1
  • 10
  • 13
  • Thank you very much for the information. Now i'm getting error in replaceInFile. Let me know what is wrong in this? [04:29:59]: replaceInFile: {"path":"/var/www/webroot/ROOT/server/php/config.inc.php","replacements":[{"pattern":"localhost","replacement":"testing"}],"nodeGroup":"nginxphp"} [04:29:59]: ERROR: [replaceInFile] {"result":11022,"source":"marketplace","error":"can't find node by the given parameters"} – John Nov 20 '18 at 04:33
  • Sorry. It was worked after added nodeType in YAML. But in documentation it was mentioned as anyone from nodeId, nodeGroup & nodeType is required. – John Nov 20 '18 at 04:53
  • I have created yaml file and site is working perfectly. Let us know how to display it in Marketplace to display it for our customers. – John Nov 20 '18 at 08:12
  • "nodeGroup": "nginxphp" is incorrect, nginxphp is a nodeType. – Virtuozzo Nov 20 '18 at 08:13
  • nodeGroup - http://docs.cloudscripting.com/creating-manifest/selecting-containers/#all-containers-by-group nodeType - http://docs.cloudscripting.com/creating-manifest/selecting-containers/#all-containers-by-type – Virtuozzo Nov 20 '18 at 08:13
  • As for your question about the Marketplace: "You can use the created manifest for the personal needs (e.g. automation of the common tasks or implementation of the complex CI/CD flows) through importing to your account. Also, the package can be shared with others via the one-click installation widgets integrated to your website. Another option is to contact hosting service providers and negotiate adding of your solution to the Jelastic Marketplace on the appropriate platform." This was described here: https://docs.jelastic.com/application-manifest – Virtuozzo Nov 20 '18 at 08:41
  • We have contacted our hosting provider "https://www.everdata.com/" in India but they have asked to access JCA marketplace. We got this message from their support team, "Please refer the same URL for Marketplace by ourselves : https://ops-docs.jelastic.com/jca-marketplace The very first image in the article shows packages in a Marketplace. Gray packages are from Jelastic Global Marketplace and can't be edited by hosting provider. So, you can add, edit, publish/unpublish and manage your own packages by yourself." – John Nov 26 '18 at 04:02
  • 1
    @John We contacted your hosting provider back and clarified that you, as end-user, can't add any packages to Marketplace but you can provide to hosting provoder the manifest, and hosting provider can review it and make decision to add it or not. The answer you got is a rephrased Jelastic reply to hosting provider. Of course, you can't add packages by yourself and have no access to Admin panel. Hope, your hosting provided will get back to you soon to solve your issue. – Virtuozzo Nov 27 '18 at 09:52