Herokuメモ(2) - heroku logs / ps

# やりたいこと
引き続き下記をやっていく
https://devcenter.heroku.com/articles/getting-started-with-php

その1は[こちら](https://qiita.com/nabechiki/items/61a880351c6ee991e626)。

## 動作環境
- Surface Go
- Windows 10 Home

## heroku logs

```
PS C:\Users\XXXX\work\php-getting-started> heroku logs --help
display recent log output

USAGE
  $ heroku logs

OPTIONS
  -a, --app=app        (required) app to run command against
  -d, --dyno=dyno      only show output from this dyno type (such as "web" or "worker")
  -n, --num=num        number of lines to display
  -r, --remote=remote  git remote of app to use
  -s, --source=source  only show output from this source (such as "app" or "heroku")
  -t, --tail           continually stream logs
  --force-colors       force use of colors (even on non-tty output)
 
DESCRIPTION
  disable colors with --no-color, HEROKU_LOGS_COLOR=0, or HEROKU_COLOR=0
```

- --tailでログの待ち受け状態になる、ここでWebアクセスしたりイベント起こすとリアルタイムでログ表示

## heroku ps

```
PS C:\Users\XXXX\work\php-getting-started> heroku ps --help
list dynos for an app

USAGE
  $ heroku ps [TYPE [TYPE ...]]

OPTIONS
  -a, --app=app        (required) app to run command against
  -r, --remote=remote  git remote of app to use
  --json               display as json

EXAMPLES
  $ heroku ps
  === run: one-off dyno
  run.1: up for 5m: bash

  === web: bundle exec thin start -p $PORT
  web.1: created for 30s

  $ heroku ps run # specifying types
  === run: one-off dyno
  run.1: up for 5m: bash

COMMANDS
  ps:autoscale  disable web dyno autoscaling
  ps:copy       Copy a file from a dyno to the local filesystem
  ps:exec       Create an SSH session to a dyno
  ps:forward    Forward traffic on a local port to a dyno
  ps:kill       stop app dyno
  ps:resize     manage dyno sizes
  ps:restart    restart app dynos
  ps:scale      scale dyno quantity up or down
  ps:socks      Launch a SOCKS proxy into a dyno
  ps:stop       stop app dyno
  ps:type       manage dyno sizes
  ps:wait       wait for all dynos to be running latest version after a release
```

- とりあえずheroku ps

```
PS C:\Users\XXXX\work\php-getting-started> heroku ps
Free dyno hours quota remaining this month: 550h 0m (100%)
Free dyno usage for this app: 0h 0m (0%)
For more information on dyno sleeping and how to upgrade, see:
https://devcenter.heroku.com/articles/dyno-sleeping

=== web (Free): vendor/bin/heroku-php-apache2 web/ (1)
web.1: up 2020/05/03 09:29:38 +0900 (~ 11m ago)
```

- このweb.1がdyno=コンテナということでいいのかな
- ps:scaleでweb=0にする

```
PS C:\Users\XXXX\work\php-getting-started> heroku ps:scale web=0
Scaling dynos... done, now running web at 0:Free
```

- もっかいheroku ps

```
PS C:\Users\XXXX\work\php-getting-started> heroku ps
Free dyno hours quota remaining this month: 550h 0m (100%)
Free dyno usage for this app: 0h 0m (0%)
For more information on dyno sleeping and how to upgrade, see:
https://devcenter.heroku.com/articles/dyno-sleeping

No dynos on ⬢ xxxxxxxx-xxxxxx-xxxxx
```

- ログからはこんな感じ

```
2020-05-03T00:48:57.802980+00:00 app[api]: Scaled to web@0:Free by user xxxx
2020-05-03T00:48:58.082661+00:00 heroku[web.1]: State changed from up to down
2020-05-03T00:48:59.088578+00:00 app[web.1]: Stopping php-fpm...
2020-05-03T00:48:59.088590+00:00 app[web.1]: SIGTERM received, attempting graceful shutdown...
2020-05-03T00:48:59.089743+00:00 app[web.1]: Stopping httpd gracefully...
2020-05-03T00:48:59.089743+00:00 app[web.1]: Stopping httpd...
2020-05-03T00:48:59.121160+00:00 app[web.1]: Shutdown complete.
```
- web=1に戻す

```
PS C:\Users\XXXX\work\php-getting-started> heroku ps:scale web=1
Scaling dynos... done, now running web at 1:Free
PS C:\Users\XXXX\work\php-getting-started> heroku ps                                                                   Free dyno hours quota remaining this month: 550h 0m (100%)
Free dyno usage for this app: 0h 0m (0%)
For more information on dyno sleeping and how to upgrade, see:
https://devcenter.heroku.com/articles/dyno-sleeping

=== web (Free): vendor/bin/heroku-php-apache2 web/ (1)
web.1: up 2020/05/03 09:46:54 +0900 (~ 1s ago)
```

- heroku logs

```
2020-05-03T00:50:53.169731+00:00 app[api]: Scaled to web@1:Free by user xxxx
2020-05-03T00:50:59.058225+00:00 app[web.1]: DOCUMENT_ROOT changed to 'web/'
2020-05-03T00:50:59.510298+00:00 app[web.1]: Detected 536870912 Bytes of RAM
2020-05-03T00:50:59.587032+00:00 app[web.1]: PHP memory_limit is 128M Bytes
2020-05-03T00:50:59.625891+00:00 app[web.1]: Starting php-fpm with 4 workers...
2020-05-03T00:50:59.862033+00:00 app[web.1]: Starting httpd...
2020-05-03T00:51:00.378596+00:00 heroku[web.1]: State changed from starting to up
```