Contents
The free plan of Heroku can run an app with limited memory, dyno, database. For keeping always on and working well, the REST API and add-ons of Heroku are helpful.
Limit
Knowing the limited resource can be better to find the solution. There are some limits that are necessary for Huginn .
- Log history: the last 1500 lines
- Memory: 512M RAM
- Dyno sleeping: web dyno receives no traffic in a 30 minute period
- Automatic dyno restarts: 24 hours + 216 random minutes
- Database(PostgreSQL): 100,000 rows
- API: a rate of at most 4500 calls per hour
Database
Keep Events
In order to conserve database space, you can choose to have events created by this Agent expire after a certain period of time. Make sure you keep them long enough to allow any subsequent Agents to make use of them (Figure 1). e.g. set Keep Events
to 3 days
for a blog or 6 hours
for an active forum.
EVENT_EXPIRATION_CHECK
Specify the frequency with which the scheduler checks for and cleans up expired events. You can use m
for minutes, h
for hours, and d
for days.
App–>Settings–>Config Variables–>Add the EVENT_EXPIRATION_CHECK
Variable. The value is 6h
defaultly, may not less than 1h
(Figure 2).
heroku run
There are two ways to run the commands heroku run
to delete the expired events and logs.
- Run Console
App–>More–>Run Console(Figure 3)
1 2 3 4 5 |
heroku run rails console AgentLog.count Event.count Event.to_expire.delete_all #delete the expired events and logs AgentLog.delete_all #delete all logs of events |
- Heroku Scheduler
Install the add-on Heroku Scheduler. Create a new job with the following command without the prefixheroku run
which has been automatically added by heroku (Figure 4).
1 |
heroku run rails runner "AgentCleanupExpiredJob.perform_later" |
Memory
Propagate immediately
Normally, Huginn moves Events from source Agents to receiving Agents once per minute. Checking this option will cause Events created by this Agent’s sources to be received immediately. This can use more CPU resources, but will decrease the time between Event creation and being received by this Agent. e.g. For the agents of creating the RSS, Propagate immediately
could set to unchecked
(Figure 1).
Running
Restart Dynos
For some reasons, the Huginn will be broken. A jobs will be running all the time, and the later ones have to delay. you can fix it by restart all dynos.
Get the API from https://dashboard.heroku.com/account–>API Key for authorizing.
Go to Heroku Scheduler
–>Create a new job with following command(Figure 4).
1 |
curl -n -X DELETE "https://api.heroku.com/apps/**app**/dynos" -H "Authorization: Bearer 898506ac-****-API*-****-fdf1b3649505" -H "Content-Type: application/json" -H "Accept: application/vnd.heroku+json; version=3" |
Always On
Install monitor add-ons, e.g. New Relic and Librato , and set the repuest to less than 30m
.
Log Management
For better debug, the log add-ons are essential for Huginn.
Papertrail:10 MB Log volume per day, 2 days Search duration, 7 days Archive duration.
Logentries: 5 GB Log volume per month, 7 days Search duration (log retention)
The Papertrail is more powerful than Logentries, comparing with search.
Dyno formation
Huginn works well with only web
dyno. No need to turn on worker
(Figure 5), that will cost extra dynos time.
Reference: