Heroku CLI
Traduzione: Copia tutti i comandi
Traduzione: Generare PDF
< >
Comandi e flussi di lavoro completi Heroku CLI per la distribuzione e la gestione delle applicazioni sulla piattaforma Heroku.
## Installazione e autenticazione
| | Command | Description | |
| --- | --- |
| | `heroku login` | Login to Heroku | |
| | `heroku login -i` | Login interactively | |
| | `heroku logout` | Logout from Heroku | |
| | `heroku auth:whoami` | Show current user | |
| | `heroku auth:token` | Display auth token | |
## Gestione delle applicazioni
### Operazioni di base delle applicazioni
| | Command | Description | |
| --- | --- |
| | `heroku apps` | List all apps | |
| | `heroku apps:create myapp` | Create new app | |
| | `heroku apps:destroy myapp` | Delete app | |
| | `heroku apps:info` | Show app info | |
| | `heroku apps:rename newname` | Rename app | |
| | `heroku apps:open` | Open app in browser | |
### Configurazione delle app
| | Command | Description | |
| --- | --- |
| | `heroku config` | Show config vars | |
| | `heroku config:set KEY=value` | Set config var | |
| | `heroku config:unset KEY` | Remove config var | |
| | `heroku config:get KEY` | Get specific config var | |
| | `heroku buildpacks` | List buildpacks | |
| | `heroku buildpacks:set heroku/nodejs` | Set buildpack | |
## Distribuzione
### Git Deploy
| | Command | Description | |
| --- | --- |
| | `git push heroku main` | Deploy from main branch | |
| | `git push heroku develop:main` | Deploy from develop branch | |
| | `heroku git:remote -a myapp` | Add Heroku remote | |
| | `heroku releases` | List releases | |
| | `heroku releases:rollback v123` | Rollback to specific release | |
### Distribuzione del contenitore
| | Command | Description | |
| --- | --- |
| | `heroku container:login` | Login to container registry | |
| | `heroku container:push web` | Build and push container | |
| | `heroku container:release web` | Release container | |
| | `heroku container:rm web` | Remove container | |
## Dynos e Scala
### Gestione di Dyno
| | Command | Description | |
| --- | --- |
| | `heroku ps` | List dynos | |
| | `heroku ps:scale web=2` | Scale web dynos | |
| | `heroku ps:scale worker=1` | Scale worker dynos | |
| | `heroku ps:restart` | Restart all dynos | |
| | `heroku ps:restart web.1` | Restart specific dyno | |
| | `heroku ps:stop web.1` | Stop specific dyno | |
### Tipi di Dyno
| | Command | Description | |
| --- | --- |
| | `heroku ps:type` | Show dyno types | |
| | `heroku ps:resize web=standard-1x` | Resize dyno type | |
| | `heroku ps:exec` | SSH into dyno | |
## Add-ons
### Gestione aggiuntiva
| | Command | Description | |
| --- | --- |
| | `heroku addons` | List app add-ons | |
| | `heroku addons:create heroku-postgresql` | Add PostgreSQL | |
| | `heroku addons:create heroku-redis` | Add Redis | |
| | `heroku addons:destroy ADDON_NAME` | Remove add-on | |
| | `heroku addons:upgrade ADDON_NAME:PLAN` | Upgrade add-on plan | |
| | `heroku addons:downgrade ADDON_NAME:PLAN` | Downgrade add-on plan | |
### Add-ons popolari
| | Command | Description | |
| --- | --- |
| | `heroku addons:create sendgrid` | Add SendGrid email | |
| | `heroku addons:create papertrail` | Add Papertrail logging | |
| | `heroku addons:create newrelic` | Add New Relic monitoring | |
| | `heroku addons:create scheduler` | Add Heroku Scheduler | |
## Operazioni di database
### PostgreSQL
| | Command | Description | |
| --- | --- |
| | `heroku pg` | List PostgreSQL databases | |
| | `heroku pg:info` | Show database info | |
| | `heroku pg:psql` | Connect to database | |
| | `heroku pg:reset DATABASE_URL` | Reset database | |
| | `heroku pg:backups` | List backups | |
| | `heroku pg:backups:capture` | Create backup | |
| | `heroku pg:backups:restore BACKUP_URL DATABASE_URL` | Restore backup | |
### Manutenzione del database
| | Command | Description | |
| --- | --- |
| | `heroku pg:maintenance` | Show maintenance info | |
| | `heroku pg:maintenance:run` | Run maintenance | |
| | `heroku pg:stats` | Show database stats | |
| | `heroku pg:diagnose` | Diagnose database issues | |
## Registrazione e monitoraggio
### Logs
| | Command | Description | |
| --- | --- |
| | `heroku logs` | Show recent logs | |
| | `heroku logs --tail` | Stream logs | |
| | `heroku logs --source app` | Show app logs only | |
| | `heroku logs --dyno web.1` | Show specific dyno logs | |
| | `heroku logs --num 1000` | Show more log lines | |
### Monitoraggio
| | Command | Description | |
| --- | --- |
| | `heroku ps:autoscale:enable` | Enable autoscaling | |
| | `heroku ps:autoscale:disable` | Disable autoscaling | |
| | `heroku metrics` | Show app metrics | |
## Domini e SSL
### Gestione del dominio
| | Command | Description | |
| --- | --- |
| | `heroku domains` | List domains | |
| | `heroku domains:add example.com` | Add custom domain | |
| | `heroku domains:remove example.com` | Remove domain | |
| | `heroku domains:info example.com` | Show domain info | |
### Certificati SSL
| | Command | Description | |
| --- | --- |
| | `heroku certs` | List SSL certificates | |
| | `heroku certs:add cert.pem key.pem` | Add SSL certificate | |
| | `heroku certs:remove` | Remove SSL certificate | |
| | `heroku certs:auto:enable` | Enable automatic SSL | |
| | `heroku certs:auto:disable` | Disable automatic SSL | |
## Pipelines and Review Apps
### Gestione delle tubature
| | Command | Description | |
| --- | --- |
| | `heroku pipelines` | List pipelines | |
| | `heroku pipelines:create mypipeline` | Create pipeline | |
| | `heroku pipelines:destroy mypipeline` | Delete pipeline | |
| | `heroku pipelines:add mypipeline --stage staging` | Add app to pipeline | |
| | `heroku pipelines:remove` | Remove app from pipeline | |
### Promozioni
| | Command | Description | |
| --- | --- |
| | `heroku pipelines:promote --remote staging` | Promote to production | |
| | `heroku releases:rollback --remote production` | Rollback production | |
### App di revisione
| | Command | Description | |
| --- | --- |
| | `heroku reviewapps:enable` | Enable review apps | |
| | `heroku reviewapps:disable` | Disable review apps | |
## Team e collaborazione
### Gestione del team
| | Command | Description | |
| --- | --- |
| | `heroku teams` | List teams | |
| | `heroku members` | List team members | |
| | `heroku members:add user@example.com` | Add team member | |
| | `heroku members:remove user@example.com` | Remove team member | |
### Controllo accessi
| | Command | Description | |
| --- | --- |
| | `heroku access` | List app collaborators | |
| | `heroku access:add user@example.com` | Add collaborator | |
| | `heroku access:remove user@example.com` | Remove collaborator | |
## CLI Plugin
### Gestione Plugin
| | Command | Description | |
| --- | --- |
| | `heroku plugins` | List installed plugins | |
| | `heroku plugins:install PLUGIN_NAME` | Install plugin | |
| | `heroku plugins:uninstall PLUGIN_NAME` | Uninstall plugin | |
| | `heroku plugins:update` | Update all plugins | |
### Plugin popolari
| | Command | Description | |
| --- | --- |
| | `heroku plugins:install heroku-repo` | Install repo plugin | |
| | `heroku repo:reset` | Reset git repository | |
| | `heroku repo:purge_cache` | Purge build cache | |
## Gestione dell'ambiente
### Più ambienti
| | Command | Description | |
| --- | --- |
| | `heroku git:remote -a myapp-staging -r staging` | Add staging remote | |
| | `heroku git:remote -a myapp-production -r production` | Add production remote | |
| | `git push staging main` | Deploy to staging | |
| | `git push production main` | Deploy to production | |
### Variabili dell'ambiente
| | Command | Description | |
| --- | --- |
| | `heroku config --remote staging` | Show staging config | |
| | `heroku config:set NODE_ENV=production --remote production` | Set production config | |
## Manutenzione e risoluzione dei problemi
### Modalità di manutenzione
| | Command | Description | |
| --- | --- |
| | `heroku maintenance:on` | Enable maintenance mode | |
| | `heroku maintenance:off` | Disable maintenance mode | |
| | `heroku maintenance` | Check maintenance status | |
### Risoluzione dei problemi
| | Command | Description | |
| --- | --- |
| | `heroku run bash` | Run bash shell | |
| | `heroku run rails console` | Run Rails console | |
| | `heroku run python manage.py shell` | Run Django shell | |
| | `heroku run node` | Run Node.js REPL | |
### Prestazioni
| | Command | Description | |
| --- | --- |
| | `heroku labs:enable preboot` | Enable preboot | |
| | `heroku labs:disable preboot` | Disable preboot | |
| | `heroku ps:wait` | Wait for dyno to be ready | |
## Migliori Pratiche
### Distribuzione
1. **Use Pipelines**: Impostare gli ambienti di messa in scena e produzione
2. ** Variabili dell'ambiente ** Conservare la configurazione in config vars
3. Migrazioni di Database. Eseguire le migrazioni durante la distribuzione
4. **Caltà Checks**: Esecuzione dei controlli sanitari
### Sicurezza
1. **SSL**: Utilizzare sempre SSL per le applicazioni di produzione
2. Separazione dell'ambiente Mantenere la messa in scena e la produzione separata
3. **Access Control**: Accesso limitato ai collaboratori
4. ** Gestione dei segreti ** Utilizza i vars di configurazione per i dati sensibili
### Prestazioni
1. #Dyno Sizing # Scegliere i tipi di dyno appropriati
2. **Caching**: strategie di campionamento
3. ** Ottimizzazione del database**: Monitorare e ottimizzare le richieste di database
4. **CDN**: Utilizzare CDN per le attività statiche
### Monitoraggio
1. **Logging**: Attuazione di registrazione completa
2. **Metrics**: Monitorare le metriche delle applicazioni
3. **Alerts**: Impostare avvisi per problemi critici
4. **Error Tracking**: Utilizzare i servizi di monitoraggio degli errori