Creating a dyno using Heroku Platform API - heroku

I tried sending a POST request to https://api.heroku.com/apps/(my-app-id)/dynos with these parameters:
Headers:
"Content-Type": "application/json",
"Authorization": "Bearer (my-api-token)",
"Accept": "application/vnd.heroku+json; version=3"
Body:
command: 'node index.js',
attach: true,
force_no_tty: null,
size: 'Free',
type: 'run',
time_to_live: 3600
After sending request this was in my heroku application console:
2019-10-29T16:53:56.305308+00:00 app[api]: Starting process with command `node index.js` by user (my-email)
2019-10-29T16:54:00.720264+00:00 heroku[run.1010]: State changed from starting to up
index.js never started and no new messages appeared. After 30 seconds i got a two new messages in console:
2019-10-29T16:54:30.482189+00:00 heroku[run.1010]: Process exited with status 128
2019-10-29T16:54:30.513621+00:00 heroku[run.1010]: State changed from up to complete
How can I create dyno correctly?

Installed heroku-client node package and... It worked!
Still don't understand why my code didn't work. ;(

Related

Resource not accessible by integration

I have this weird error when Cypress GitHub Action can't successfully complete whilst CLI command is doing just fine.
Here is how I tried to do it originally with GitHub Action:
- name: Run acceptance tests with Cypress 📝
uses: cypress-io/github-action#v2
with:
working-directory: e2e
browser: chrome
record: true
parallel: true
start: npm run start-server
wait-on: 'http://localhost:1080'
wait-on-timeout: 360
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
MIX_ENV: acceptance_tests
DEBUG: '#cypress/github-action'
Here is my cypress.json config - you can see that wait-on and baseUrl are pointing to the same URL:
{
"testFiles": "**/*.feature",
"projectId": "...",
"baseUrl": "http://localhost:1080"
}
And the fun fact is that app under test responds to at least one request!
arning: 2022-05-18T21:04:34.089Z #cypress/github-action Separated 1 start commands npm run app_server
start server "npm run app_server command "npm run app_server"
current working directory "/__w/mimisbrunnr/mimisbrunnr/e2e"
2022-05-18T21:04:34.090Z #cypress/github-action parsed command: npm run app_server
waiting on "http://localhost:1080" with timeout of 60 seconds
Warning: 2022-05-18T21:04:34.091Z #cypress/github-action Waiting for urls http://localhost:1080
2022-05-18T21:04:34.092Z #cypress/github-action Waiting for url http://localhost:1080
Warning: 2022-05-18T21:04:34.092Z #cypress/github-action total ping timeout 90000
2022-05-18T21:04:34.092Z #cypress/github-action individual ping timeout 30000ms
Warning: 2022-05-18T21:04:34.092Z #cypress/github-action retries limit 3
2022-05-18T21:04:34.107Z #cypress/github-action got error {"name":"RequestError","code":"ECONNREFUSED","timings":{"start":1652907874098,"socket":1652907874099,"lookup":1652907874100,"error":1652907874101,"phases":{"wait":1,"dns":1,"total":3}}}
Warning: 2022-05-18T21:04:34.107Z #cypress/github-action 15ms undefined undefined ECONNREFUSED attempt 1
2022-05-18T21:04:34.108Z #cypress/github-action found command "/usr/local/bin/npm"
Warning: 2022-05-18T21:04:34.108Z #cypress/github-action with arguments run app_server
2022-05-18T21:04:34.108Z #cypress/github-action running "/usr/local/bin/npm" run app_server in /__w/mimisbrunnr/mimisbrunnr/e2e
Warning: 2022-05-18T21:04:34.108Z #cypress/github-action waiting for the command to finish? false
/usr/local/bin/npm run app_server
> gjallarhorn#1.0.0 app_server
> cd ../main && mix phx.server
here it comes ->
warning: the VM is running with native name encoding of latin1 which may cause Elixir to malfunction as it expects utf8. Please ensure your locale is set to UTF-8 (which can be verified by running "locale" in your shell)
2022-05-18T21:04:35.109Z #cypress/github-action got error {"name":"RequestError","code":"ECONNREFUSED","timings":{"start":1652907875108,"socket":1652907875108,"lookup":1652907875108,"error":1652907875109,"phases":{"wait":0,"dns":0,"total":1}}}
Warning: 2022-05-18T21:04:35.109Z #cypress/github-action 1017ms undefined undefined ECONNREFUSED attempt 2
21:04:35.419 [info] Running MimisbrunnrWeb.Endpoint with cowboy 2.9.0 at 127.0.0.1:1080 (http)
21:04:35.428 [info] Access MimisbrunnrWeb.Endpoint at http://localhost:1080
[+] Starting static assets build with esbuild. Build mode development...
[+] Starting static assets build with esbuild. Build mode development...
21:04:36.251 request_id=FvBO9LpFQLx0rPYAAAFx [info] GET /
21:04:36.339 request_id=FvBO9LpFQLx0rPYAAAFx [info] Sent 200 in 87ms
2022-05-18T21:04:36.348Z #cypress/github-action pinging http://localhost:1080 has finished ok after 2256ms
but even though cypress successfully pinged the main app the party is still over
Warning: 2022-05-18T21:04:36.349Z #cypress/github-action Running Cypress tests using NPM module API
2022-05-18T21:04:36.349Z #cypress/github-action requiring cypress dependency, cwd is /__w/mimisbrunnr/mimisbrunnr
Warning: 2022-05-18T21:04:36.349Z #cypress/github-action working directory /__w/mimisbrunnr/mimisbrunnr/e2e
2022-05-18T21:04:36.351Z #cypress/github-action resolved cypress /__w/mimisbrunnr/mimisbrunnr/e2e/node_modules/cypress/index.js
Warning: 2022-05-18T21:04:36.721Z #cypress/github-action Cypress config "pageLoadTimeout=100000,baseUrl=http://localhost:1080"
2022-05-18T21:04:36.722Z #cypress/github-action Determining build id by asking GitHub about run 2348169225
Warning: 2022-05-18T21:04:36.841Z #cypress/github-action Resource not accessible by integration
2022-05-18T21:04:36.841Z #cypress/github-action HttpError: Resource not accessible by integration
Warning: at /__w/_actions/cypress-io/github-action/v2/dist/index.js:58740:21
at processTicksAndRejections (internal/process/task_queues.js:97:5)
Warning: at async getCiBuildId (/__w/_actions/cypress-io/github-action/v2/dist/index.js:6230:18)
at async runTests (/__w/_actions/cypress-io/github-action/v2/dist/index.js:6468:33)
Error: Resource not accessible by integration
Ok. Fair enough, but look - it's all fine with a simple CLI command run through start-server-and-test. Here is the relevant part of the package.json:
"scripts": {
"test": "cypress run",
"start-server": "cd ../main && mix phx.server",
"ci": "start-server-and-test start-server http://localhost:1080 test"
}
and GitHub Action step:
- name: Run acceptance tests with Cypress
run: npm run ci
working-directory: e2e
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
MIX_ENV: acceptance_tests
START_SERVER_AND_TEST_INSECURE: 1
DEBUG: start-server-and-test
and logs:
making HTTP(S) head request to url:http://localhost:1080 ...
21:40:36.375 request_id=FvBQ66vDSZ10rPYAAAES [info] HEAD /
21:40:36.548 request_id=FvBQ66vDSZ10rPYAAAES [info] Sent 200 in 172ms
HTTP(S) result for http://localhost:1080: {
Warning: status: 200,
statusText: 'OK',
headers: {
'cache-control': 'max-age=0, private, must-revalidate',
connection: 'close',
'content-length': '3910',
'content-type': 'text/html; charset=utf-8',
'cross-origin-window-policy': 'deny',
date: 'Wed, 18 May 2022 21:40:36 GMT',
Warning: server: 'Cowboy',
'x-content-type-options': 'nosniff',
'x-download-options': 'noopen',
'x-frame-options': 'SAMEORIGIN',
'x-permitted-cross-domain-policies': 'none',
'x-request-id': 'FvBQ66vDSZ10rPYAAAES',
'x-xss-protection': '1; mode=block',
'set-cookie': [
'_app_web_key=SFMyNTY.g3QAAAABbQAAAAtfY3NyZl90b2tlbm0AAAAYdmc0cXlvMkVha3JhcS1hVEJpalFxQ0J5.28LG5PrAPHrEQfvD1fpHR2-pLeEDgRrZkox8--yxP9M; path=/; HttpOnly'
]
},
data: ''
}
2022-05-18T21:40:36.564Z start-server-and-test waitOn finished successfully
Warning: 2022-05-18T21:40:36.565Z start-server-and-test running test script command: npm run test
wait-on(3361) complete
[+] Esbuild /__w/mimisbrunnr/mimisbrunnr/main/apps/mimisbrunnr_web/assets/js/app.js to /__w/mimisbrunnr/mimisbrunnr/main/apps/mimisbrunnr_web/priv/static/assets/app.js succeeded.
[+] Esbuild /__w/mimisbrunnr/mimisbrunnr/main/apps/mimisbrunnr_web/assets/css/app.scss to /__w/mimisbrunnr/mimisbrunnr/main/apps/mimisbrunnr_web/priv/static/assets/app.css succeeded.
> gjallarhorn#1.0.0 test
> cypress run
[3631:0518/214038.922826:ERROR:gpu_init.cc(453)] Passthrough is not supported, GL is swiftshader, ANGLE is
mail server at port 7777
====================================================================================================
(Run Starting)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 9.6.0 │
│ Browser: Electron 94 (headless) │
│ Node Version: v16.14.0 (/usr/local/bin/node) │
│ Specs: 2 found (patient_dashboard.feature, sign_up.feature) │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
So my question is what exactly resource is not accessible by the integration?

ElasticSearch and Apm search phase execution exception: [script_exception] Reason: link error

I installed ElasticSrarch and Kibana after that added integrated fleet and Apm on windows server 2019 and 2022 (both active now and all stack version is 8.1.2). for client I use AspNetCore sample form OpenTelemetry Github repository. I haven't any problem When I send Apm to windows server 2022 but when I send to 2019 and try access apm services from observability I get below error.
And this error logged:
[2022-04-18T14:34:22.619+04:30][ERROR][plugins.apm] Error: search_phase_execution_exception: [script_exception] Reason: link error
at D:\ElasticStack\kibana\x-pack\plugins\observability\common\utils\unwrap_es_response.js:60:11
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at getServiceInstancesSystemMetricStatistics (D:\ElasticStack\kibana\x-pack\plugins\apm\server\routes\services\get_service_instances\get_service_instances_system_metric_statistics.js:126:20)
at async Promise.all (index 1)
at D:\ElasticStack\kibana\x-pack\plugins\apm\server\routes\services\get_service_instances\main_statistics.js:28:51
at async Promise.all (index 0)
at handler (D:\ElasticStack\kibana\x-pack\plugins\apm\server\routes\services\route.js:622:45)
at D:\ElasticStack\kibana\x-pack\plugins\apm\server\routes\apm_routes\register_apm_server_routes.js:143:13
at Router.handle (D:\ElasticStack\kibana\src\core\server\http\router\router.js:163:30)
at handler (D:\ElasticStack\kibana\src\core\server\http\router\router.js:124:50)
at exports.Manager.execute (D:\ElasticStack\kibana\node_modules\#hapi\hapi\lib\toolkit.js:60:28)
at Object.internals.handler (D:\ElasticStack\kibana\node_modules\#hapi\hapi\lib\handler.js:46:20)
at exports.execute (D:\ElasticStack\kibana\node_modules\#hapi\hapi\lib\handler.js:31:20)
at Request._lifecycle (D:\ElasticStack\kibana\node_modules\#hapi\hapi\lib\request.js:371:32)
at Request._execute (D:\ElasticStack\kibana\node_modules\#hapi\hapi\lib\request.js:281:9)
Response: {
error: {
root_cause: [
{
type: 'script_exception',
reason: 'link error',
script_stack: [ "doc['system.memory.actual.free']", ' ^---- HERE' ],
script: "1 - doc['system.memory.actual.free'] / doc['system.memory.total']",
lang: 'expression'
}
],
type: 'search_phase_execution_exception',
reason: 'all shards failed',
phase: 'query',
grouped: true,
failed_shards: [
{
shard: 0,
index: '.ds-metrics-apm.internal-default-2022.04.17-000001',
node: 'KsqpLySITbOWAlCPlvsdSg',
reason: {
type: 'script_exception',
reason: 'link error',
script_stack: [ "doc['system.memory.actual.free']", ' ^---- HERE' ],
script: "1 - doc['system.memory.actual.free'] / doc['system.memory.total']",
lang: 'expression',
caused_by: {
type: 'parse_exception',
reason: 'Field [system.memory.actual.free] does not exist in mappings'
}
}
}
]
},
status: 400
}
I compare both servers and agents configs but I can't find any differences. Why this message and error appears and how can I solve it?
I found the problem two weeks ago, and After some busy days, I will send it here. Also, I think It's a bug.
In a general and fast answer, you should add APM metrics that contain CPU and memory benchmarks. In the below lines, I describe my case in detail.
Windows Server 2022 VPS is a development test environment, and I started my project with the Elastic APM library. This library collects CPU and memory metrics and sends them as APM Metrics by default configurations. After that, I changed my library and used OpentTelemetry. The new one does not send CPU and memory benchmarks, and I ignore it on tests because it's not noticeable for my usage. When I moved from the development to the staging environment with a clean installation of Elastic, an error appeared. After some debugging, I find that the problem solves if I add CPU and Memory metrics. I added metrics by sending them with my first Elastic APM Library, but others can use Kibana and add some fake metrics. For the second approach, you can see the Ovidiu comment.

bash: node-v0.10.20-linux-x64/bin/node: No such file or directory

I was following this tutorial to release Programmatically code to Heroku and i was able to deploy the slug on heroku with this results:
{ addon_plan_names: [],
app:
{ id: 'a247a2f8-fa1a-48ea-8b89-96b1f924093a',
name: 'arcane-plateau-99175' },
created_at: '2019-10-29T04:25:17Z',
description: 'Deploy',
status: 'succeeded',
id: 'e12da0fd-c12a-4872-b580-49ea49259863',
slug: { id: '1b72b657-e2cf-49e2-8e0a-94ec94de8559' },
updated_at: '2019-10-29T04:25:17Z',
user:
{ email: '******#gmail.com',
id: '63bb3b9a-6349-44e4-8cb4-ba54d6ee7b34' },
version: 3,
current: true,
output_stream_url: null }
I also created ./app folder
and added the 2 files:
http://nodejs.org/dist/v0.10.20/node-v0.10.20-linux-x64.tar.gz
web.js
then i converted the "app" folder into slug.tgz file. Once i deploy the slug, i get the error:
2019-10-29T04:32:20.182896+00:00 heroku[web.1]: State changed from crashed to starting
2019-10-29T04:32:20.492003+00:00 heroku[web.1]: Starting process with command `node-v0.10.20-linux-x64/bin/node web.js`
2019-10-29T04:32:22.807892+00:00 heroku[web.1]: Process exited with status 127
2019-10-29T04:32:22.896147+00:00 heroku[web.1]: State changed from starting to crashed
2019-10-29T04:32:22.733421+00:00 app[web.1]: bash: node-v0.10.20-linux-x64/bin/node: No such file or directory
What i am doing wrong here?
The documentation you're looking at allows you to create slugs (a container image) from scratch.
When doing that, you need to include node within the slug by yourself.
You may be looking for the Heroku documentation on building and releasing using the Platform API instead.
This API will let you create builds with your code base. You will pass a tar containing your uncompiled source code to Heroku, and they will build it using buildpacks. In your case, the node one.

heroku apps not running forever script.js

I have a heroku app created on my local system and pushed it to heroku then i ran
heroku run node_modules/forever/bin/forever start server.js
and i got this response -
warn: --minUptime not set. Defaulting to: 1000ms
warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms
info: Forever processing file: server.js
and after that if i run
heroku run node_modules/forever/bin/forever list
I got -
Running `node_modules/forever/bin/forever list` attached to terminal... up, run.5132
info: No forever processes running
and the heroku logs here have -
Starting process with command `node_modules/forever/bin/forever start server.js` by harshitladdha93#gmail.com
2014-07-05T17:24:54.833343+00:00 heroku[run.5098]: State changed from starting to up
2014-07-05T17:24:58.695683+00:00 heroku[run.5098]: State changed from up to complete
2014-07-05T17:24:58.689043+00:00 heroku[run.5098]: Process exited with status 0
this, and my server.js has -
var async = require('async');
var shell = require('shelljs');
async.parallel([
async.apply(shell.exec, './collect1.sh'),
async.apply(shell.exec, './collect2.sh'),
async.apply(shell.exec, './collect3.sh'),
async.apply(shell.exec, './collect4.sh'),
async.apply(shell.exec, './collect5.sh'),
async.apply(shell.exec, './mi2.sh'),
],
function (err, results) {
console.log(results);
});
and these shell scripts are long executing files with huge amount of delays but the logs say that the state from up to complete, but I don't understand why as in my local system it creates more processes and sleep states and it runs fine
so, heroku doesn't allow this or I am making some mistake here.

jQuery ajax Authorization Token Header Fails

jQuery 1.9.1
The request never gets sent and seems to just error out. console.log output shows Request failed: error I do not know how to debug this further.
$.ajax({
beforeSend: function (xhr) { xhr.setRequestHeader ('Authorization', 'Token c576f0136149a2e2d9127b3901015545') },
type: "GET",
url: "https://example.com/endpoint",
dataType: "json"
}).done(function( msg ) {
console.log( msg );
}).fail(function(jqXHR, textStatus, errorThrown) {
console.log( "Request failed: " + textStatus );
console.log( errorThrown );
});
Inspecting the network traffic in google chrome shows
Method: OPTIONS
Status: (canceled)
Type: Pending
However using curl works fine:
curl https://example.com/endpoint -H 'Authorization: Token token="c576f0136149a2e2d9127b3901015545"'
Here is the jsFiddle: http://jsfiddle.net/2vtyD/1/
Note: this is not an issue with Access-Control-Allow-Origin as I have this part working.
I know I must be missing something...
Update:
Everything works fine when I switch to http. It is only when using https this problem occurs. I thought it might be because I am using a self-signed certificate (invalid). But other SSL requests (non-authorization ie not 'OPTIONS' ) work just fine. So it only seems to be a combination of SSL and OPTIONS requests. The status in chrome says canceled and from looking at the server logs apache logs shows some activity but it never makes it the rails web app.
Here is a sniplet of the apache log:
[info] [client 10.0.2.2] (70007)The timeout specified has expired: SSL input filter read failed.
[info] [client 10.0.2.2] Connection closed to child 10 with standard shutdown (server example.com:443)
[info] [client 10.0.2.2] Connection to child 11 established (server example.com:443)
[info] Seeding PRNG with 656 bytes of entropy
[info] [client 10.0.2.2] (70014)End of file found: SSL input filter read failed.
[info] [client 10.0.2.2] Connection closed to child 11 with standard shutdown (server example.com:443)
However, these types of messages are occurring for all SSL requests. So I am basically at a loss on how to proceed.
Use a valid SSL certificate.
For some reason GET, POST, PUT and DELETE requests work fine with a self signed certificate. But OPTIONS request does not. Using a valid SSL certificate everything will work fine.

Resources