Cannot load API Definition from files at v1.9

Imported Google Group message. Original thread at: Redirecting to Google Groups Import Date: 2016-01-19 21:44:22 +0000.
Sender:Angus Tse.
Date:Tuesday, 19 January 2016 03:44:25 UTC.

using v1.9 with vagrant setup

I copy and pasted this Definition file (link) and store as /etc/tyk/apps/test.json
vagrant@precise64:/opt/tyk-gateway/apps$ ls -al /etc/tyk/apps/
total 12
-rw-r–r-- 1 root root 729 Jan 19 03:04 test.json
{
“name”: “Tyk Test API”,
“api_id”: “1”,
“org_id”: “569c53ca56c02c0f5c000001”,
…}

restart services
vagrant@precise64:/opt/tyk-gateway/apps$ sudo service tyk-gateway restart
tyk-gateway stop/waiting
tyk-gateway start/running, process 1871

but the i didn’t file the API from http://my-awesome-portal.com:3000/admin/organisations/

{
“id”: “569c53ca56c02c0f5c000001”,
“owner_name”: “Default Org.”,
“owner_slug”: “default”,
“cname_enabled”: true,
“cname”: “”,
“apis”: [
{
“api_human_name”: “Test API”,
“api_id”: “a46ef49d124041b3509fdf273ea2e7ef”
},
{
“api_human_name”: “test falcor”,
“api_id”: “30dfc3916f42479144747c13588070e5”
}
],
“developer_quota”: 0,
“developer_count”: 0,
“event_options”: {},
“hybrid_enabled”: false,
“ui”: {
“login_page”: {},
“nav”: {},
“uptime”: {},
“portal_section”: {},
“designer”: {}
}
}…

both http://my-awesome-portal.com:8080/tyk/reload http://my-awesome-portal.com:3000/tyk/reload also report 404 to me

  • others api / admin api are working to me

Imported Google Group message.
Sender:Angus Tse.
Date:Tuesday, 19 January 2016 03:53:33 UTC.

the new api can be add if I paste the test.json code to http://my-awesome-portal.com:3000/#/apis
BUT, I still prefer to add API via FILE. Any hints ?

  • show quoted text -

Imported Google Group message.
Sender:Martin Buhr.
Date:Tuesday, 19 January 2016 06:54:16 UTC.

Hi Angus,

You either have the dashboard - where it is managed by DB OR you have no dashboard where it is managed by file.

You might be able to do both but it basically cripples the dash

To switch, you need to edit the Tyk.conf to not use DB backed configs (run the setup.sh without the dashboard param, see the installation options)

Cheers,
Martin

  • show quoted text -

  • show quoted text -


You received this message because you are subscribed to the Google Groups “Tyk Community Support” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web, visit https://groups.google.com/d/msgid/tyk-community-support/99c25aff-fb49-4ced-b98b-d7703e9c1103%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Imported Google Group message.
Sender:Angus Tse.
Date:Tuesday, 19 January 2016 08:08:02 UTC.

Hi Martin

Thanks for your response. very appreciate your works.
I just know that I can add API on either FILE / Dashboard.

Q1. Is it means Analytic tracking also disabled if remove this option --dashboard=1 from setup.sh ?
Q2. For my use case, I am considering how to manage API definition version using Github and automate deployment. The dashboard quite useful for me, I may consider to use /api/apis/ to update / create API with my Github source. Any thoughts ?

BTW, sorry that, I may submit duplicated topics about “Failed to load Middleware JS”. Feel free to ignore either one.

  • show quoted text -

Imported Google Group message.
Sender:Martin Buhr.
Date:Tuesday, 19 January 2016 09:57:42 UTC.

Hi Angus,

No problem :slight_smile:

Yes basically if you want to use the dashboard, you’ll need to use the DB and the Advanced API to manage your definitions. If you leave out the dashboard=1 parameter, then a different base configuration will be used for your setup (one that is geared towards file-based deployment).

You would need to manually modify the tyk.conf file to get it to collect analytics for you but not manage APIs (whole swathes of the dashboard UI would be useless, like key management).

You could do something tricky by mirroring the API definitions (importing) them into the dashboard, then you could mange keys too since the api IDs would match up with what is on disk.

But it’s not really recommended :wink:

Cheers,
Martin

  • show quoted text -

  • show quoted text -

To view this discussion on the web, visit https://groups.google.com/d/msgid/tyk-community-support/f6f1334a-21e7-4fdb-b80b-9f7872051a48%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Still cannot load api definition from files.
I removed --dashboard=1 from the setup script and restarted both tyk-dashboard & gateway service.

http://my-awesome-portal.com:3000/admin/organisations/

{
  "organisations": [
    {
      "id": "56a0afa756c02c0a3c000001",
      "owner_name": "Default Org.",
      "owner_slug": "default",  ...
      "apis": [], ...

tyk.conf

{
  "listen_port": 8080,  ...
  "use_db_app_configs": false, ...
  "enable_analytics": false, ...

Gateway Log:

INFO[0000] Hostname set:
INFO[0000] Connection dropped, connecting..
INFO[0000] Setting up Server
INFO[0000] --> Standard listener (http)
INFO[0000] Loading API Specification from /opt/tyk-gateway/apps/app_sample.json
INFO[0000] Loading API Specification from /opt/tyk-gateway/apps/test_post.json
INFO[0000] Detected 2 APIs
INFO[0000] --> Loading API: Tyk Test API
INFO[0000] ----> Tracking: (no host)
INFO[0000] ----> Checking security policy: Token
INFO[0000] --> Loading API: test get param
INFO[0000] ----> Tracking: (no host)
INFO[0000] ----> Checking security policy: Token
INFO[0000] Loading uptime tests...
INFO[0000] Gateway started (v1.9.1.1)
INFO[0000] --> Listening on port: 8080
INFO[0010] [HOST CHECK MANAGER] Starting Poller

apps/app_sample.json

{
    "name": "Tyk Test API",
    "api_id": "1",
    "org_id": "56a0afa756c02c0a3c000001", ...

But the Gateway output confirms that the definition is being loaded from file?

In fact, it’s loading two APIs from the apps directory directory…

Your orgs will not update with file based API’s, you would need to add then to the dashboard as duplicates.

Mixing dashboard and file based is really not recommended, it’s either one or the other.

Thanks,
Martin

I am a bit confused. Correct me if I am wrong.

If I would like to use file based API definition then I would

  1. /opt/tyk-gateway/install/setup.sh without dashboard options
  2. run /opt/tyk-dashboard/install/setup.sh as document so that I can make use the Advanced Management API
  3. create ORG & API Key via Advanced Management API
  4. create API Definitions and Policies using file basesd

If i want to check my API definition created by File, I should use:
GET 127.0.0.1:8080/tyk/apis/ to check it instead of Advanced Management API / Dashboard

Hi Angus,

  1. Yes
  2. No: Advanced API is useless with gateways that are not listening to the DB
  3. Redundant
  4. Redundant

Basically, if you want to use the Dashboard, you need gateways to be DB backed, not file based. They are not mixable, it’s either one or the other type of isntallation. Gateway only vs. DB Backed with dashboard.

You can try and mix and match, but then you need to duplicate APIs in Dashboard AND file. As I said, it’s really not recommended.

In your tyk.conf you need to disable use_db_app_configs, then duplicate everything in the dashboard manually, after that, it’s unknown territory as you’re using the stack in a way that we don’t endorse, test or support - so it’s all supposition from here on on my part :slightly_smiling:

Cheers,
M.