Have Heroku App Restart it self from Heroku - heroku

So, if I run the command heroku ps:restart event_machine.1 --app app-name I get what I want. However, I'm trying to automate our travis-ci deploy process. What needs to happen is the following:
We have a successful test run.
Next, we deploy the code
If we deploy the code successfully, we need to execute a few rake tasks that tell an external service to rebuild it self.
Once this is fired off, we need to restart the heroku app. In travis, ideally, this would be executed on the heroku machine via a deploy run command. This would be done in much the same way that we run bundle exec db:migrate.
Does anyone have any thoughts on how we we can restart a particular dyno(s) via a command that can be ran via heroku run something as that is what travis is executing in the deploy run.

So, to answer this we had a procfile that is executing a rake command to spin up event machine. We've modified this at the proc file level to first tell the external service to rebuild it self, before starting the event machine. This takes travis completely out of the deployment loop, which is better because it allows Heroku and Travis to each do what they should be responsible for.

Related

Jenkins : run app and command in same time

I want to know if it exists a way or not to run an app in Jenkins job then run commands meanwhile app is running. I explain my situation, I need to audit my website in my pipeline with Asqatasun services but to do it I need to have an app is running. The problem is : if my app is running, commands below are not going to be executed until app is going shutdown.
Do you know a way to run an app and execute command in same time please ?
You can run your pipeline while your app is up and running. Jenkins pipeline has it's own workspace where your pipeline will be executed under the jenkins user. There your code will be cloned and all commands will be executed. It won't affect your on going running app.

How can I debug my failed deployment on Heroku?

Trying to deploy a Node app and usually have no issues at all. Now I'm having TypeScript resolution errors that only fail on Heroku but work locally and I have no idea how to test it ON Heroku.
I know I can do heroku run bash but then I'm just in an empty directory without my code.
I'd like to heroku run bash after the failed build and look around and run my commands as Heroku would so I can see why I'm having module resolution errors.
Can't find anything about it on Google whatsoever

How to debug an Heroku app, since logs don't help att all?

I'm trying to deploy a nodejs app on heroku for the first time, but I'm stuck at the command "heroku open" since it gives me an application error and no information as to where it crashed. The app runs locally without problem.
How would you proceed to debug this?
Thanks for your advice and time.
If running heroku local does not help, run a remote shell:
heroku run -a <your app name> /bin/bash, and there run npm start to see the logs and debug the issue on the Heroku server.
When running your app "locally", have you tried running heroku local? This runs the app through Heroku, but on local server.

What is a good way to run a task whenever a Heroku app restarts?

Use case is to bust the cache.
What is a good way to run given code (or rake task) whenever a Ruby Heroku app is restarted (or deployed)?
There's no way to do this via the Heroku API far as I know. The Heroku Platform API doesn't support this.
What you can do (if you're fast, however!) is listen for a SIGTERM message in your code (that's what Heroku sends to your application process when it attempts to restart it) -- you can then fire off your script quickly.
Here's more information on SIGTERM on Heroku: https://devcenter.heroku.com/articles/dynos#graceful-shutdown-with-sigterm
If you're using some sort of CI, you can probably configure it there. Heres how to do it with CircleCI:
deployment:
production:
branch: production
commands:
- git push git#heroku.com:foo-bar-123.git $CIRCLE_SHA1:master
- heroku run rake <your task> --app <your app name>
If you're not using a CI you can still whip together a script that first does the git push to Heroku and then executes your cache busting task through heroku run (the app's bin/ folder would be an obvious place to put it).
Note: you can also use heroku run:detached, which will send output to your logs instead of stdout.
You can use "release" feature that allows you to run any command before a new release is deployed. https://devcenter.heroku.com/articles/release-phase
Define the command that should be run in your Procfile.
release: rake db:migrate
From documentation:
The release command is run immediately after a release is created, but before the release is deployed to the app’s dyno formation. That means it will be run after an event that creates a new release.

How to use Heroku-Scheduler

I've recently installed https://addons.heroku.com/scheduler in my heroku app, but I just cannot make any instruction get to work.
I think I don't know the correct syntax, for now I've tried with heroku pgbackups:capture --expire --app running-app command and selected frequency 10 mins.
It's been more than an hour and still hasn't done anything.
How can I get this to work?
Thanks
EDIT: This command is an example command, nor that I want to use that one specifically
You should be using the pgbackups addon, https://addons.heroku.com/pgbackups which is scheduled for you based on the level you pick.
Heroku Scheduler is more for if you need to run a rack task within your application codebase.
UPDATE BASED ON REVISED QUESTION:
You would write a rake task (assuming your using Rails?) which you could run locally using rake taskname and to schedule it on Heroku you would enter rake taskname as the command in the scheduler page for them to execute it.

Resources