I created a web-crawler in Python and uploaded it to Heroku. To prevent my app from sleeping, how do I use Heroku Scheduler to ping my app daily?
What is the command am I supposed to use in "Enter a command and select a dyno size to use for this job."?
I guess I have to write a Ping script in Python and upload to Heroku first. But I have no idea how to write a Ping script
I can't find anything via Google on my queries. At
https://devcenter.heroku.com/articles/scheduler
it doesn't explain the code to use for Python
Appreciate some help. Thank you
Related
I have a discord bot that saves JSON files on the same directory he is in so it could work on more than one server without colliding (he saves variables that are not important to the question) .
I finished my code and I uploaded it to heroku for hosting. The thing is , when I ran the code from my pc I could see the files that were being created for each server for testing but now I don't know how to reach them.
Is there a way to check all the files I have in heroku?
(when I mean all, I mean also the JSON files that were created from the bot itself)
side not:
You can do heroku run bash -a APPNAME but it still doesn't let me see the files that were made in the dyno or directory.
On top of that, if someone has another good hosting site(preferred free) which doesn't use a ephemeral filesystem, that would be great if you can comment them down bellow.
(or if you have a way to save the files before the dyno deletes them)
What you are searching for in Heroku is called Heroku Exec (SSH Tunneling) which you can use to SSH into running dynos for debugging purposes.
I'm creating a Discord bot and I've decided to use the Google Translation API to make the bot translate text between different languages on request.
However, at each initiation of the bot, I am required to run a Powershell command for the Discord bot to have the Translation feature enabled. Without, the command does not work.
The command is as follows: $env:GOOGLE_APPLICATION_CREDENTIALS="C:\Users\username\Downloads\[FILE_NAME].json"
This points the bot to the Service Key for the Google Translate API Project.
Full documentation here: Documentation
This would work perfectly if I intended to only run it on my machine, but I want to run it 24/7 on a server, and I have Heroku already set up.
How would I go about setting this up on a server, because at the moment, I have no clue.
All help would be appreciated.
Thank you.
The command you're using is to declare an environment variable.
Node.js
You can do it as answered here:
GOOGLE_APPLICATION_CREDENTIALS="/absolute/path/to/key.json" node index.js
Heroku
You can also set the env var directly on Heroku (documentation):
heroku config:set GOOGLE_APPLICATION_CREDENTIALS=/absolute/path/to/key.json
Docker
Alternatively, you can create a Docker image or build it with Heroku and set the env variables in Docker.
Heroku Docker and Docker env file / Docker compose env var
I have a script written in Golang that does some http requests and store information in an external database. I want this script to be run once a day at a time that i set. Now i'm dealing with how to deploy it and my first option is Heroku since that's the platform i'm most familiar with. My problem is that i don't want the script to be run when i deploy it for the first time or every time i deploy an update.
Instead i was thinking about using scheduler add-on and set a time for the script to be executed. Is this possible or is there a more effective configuration for the script to be run only at a specified time?
Thank you in advance for your answers!
You should use gocron https://github.com/jasonlvhit/gocron
and run permanent your dino on heroku
in gocron you can shedule your services
gocron.Every(1).Second().Do(task)
gocron.Every(2).Seconds().Do(task)
gocron.Every(1).Minute().Do(task)
gocron.Every(2).Minutes().Do(task)
gocron.Every(1).Hour().Do(task)
gocron.Every(2).Hours().Do(task)
gocron.Every(1).Day().Do(task)
gocron.Every(2).Days().Do(task)
You can use heroku scheduler, you can give it a command to run and choose how often you want to run it and heroku runs it for you.
I need to programmatically execute a command on a Heroku app that I created used their REST API. From my console, I'd regularly do it like so:
$ heroku run [command]
I'm looking for a REST API request like this one:
POST /apps/{app_id}/run
But I was unable to find it in on the docs and I just resign to acknowledge that's not implemented. It's too much of a default behavior.
I know I could just install the Heroku Toolbelt on the requester box, but I don't like that. I could also set an authenticated URL to fire the thing but that's also too much of a thing for a feature that's already there!
This is what you're looking for: https://devcenter.heroku.com/articles/platform-api-reference#dyno-create
Notice the example there -- you can specify a run type which will run the process as a one-off thing. This is exactly how the heroku run command works under the hood =)
Well, my head is spinning a bit here. I started with what i thought would be a simple task, to take regular db dumps on heroku and push them to a personal S3 account for backup.
I am not sure the best a approach to do this. Accessing S3 within Java is crystal clear, getting the db dump from heroku is clear as mud right now...
Disclaimer: i don't know Ruby, and i don't really want to learn Ruby if i don't have to, i really want to use Java (that is why i chose play) and i want to have it hosted, that is why i chose Heroku :-)
So, I could use the heroku Scheduler, but i am not understanding what scripts are being executed here - is it all scripts in /bin? What kind of scripts are these, are they ruby scripts? How do i add them as 'tasks' when they aren't rake tasks?
Can I use the pgbackups via URL somehow? It looks like the rake examples do pg_dump instead, write to a tmp file and then move it around from there. I'm pretty unclear how to access the heroku databased stuff from a script, the examples i have seen so far are in rake, so any insight there would be helpful...
Or coming at it from inside my java app, what is the status of the Heroku java API? If there is a way to get to the heroku runtime from my java, or somehow use the heroku.jar?
It would great to get some overall guidance and best practices in this area - thanks!!!
From the google group i found this tidbit:
http://groups.google.com/group/heroku/browse_thread/thread/7fe984c3d2d01f21/9474f31138636332?lnk=gst&q=scheduler+#9474f31138636332
"Sorry for the delayed response. We updated the docs to mention running Procfile entries via heroku run:
http://devcenter.heroku.com/articles/oneoff-admin-ps
Anything that works via heroku run works via Heroku Scheduler. Just put the name of the process type as the 'task" in Scheduler. No special syntax required. And you can even pass it arguments. "
From this and James Ward's last example above i am considering this answered.