Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log rotation #273

Open
thedotedge opened this issue Nov 24, 2021 · 4 comments
Open

Log rotation #273

thedotedge opened this issue Nov 24, 2021 · 4 comments
Labels
Request Request for image modification or feature

Comments

@thedotedge
Copy link

Hi,
It would be great to have logrotate preconfigured, since /var/lib/ghost/content/logs folder is ever-growing. That cause issues when deploying to k8s, since pod would eventually crash:

[ghost-56f4c644f9-gps8f ghost]  [2021-11-24 15:46:52] �[36mINFO�[39m Ghost server started in 0.512s
[ghost-56f4c644f9-gps8f ghost]  events.js:377
[ghost-56f4c644f9-gps8f ghost]        throw er; // Unhandled 'error' event
[ghost-56f4c644f9-gps8f ghost]        ^
[ghost-56f4c644f9-gps8f ghost]  
[ghost-56f4c644f9-gps8f ghost]  Error: ENOSPC: no space left on device, write
[ghost-56f4c644f9-gps8f ghost]  Emitted 'error' event on Logger instance at:
[ghost-56f4c644f9-gps8f ghost]      at WriteStream.onStreamError (/var/lib/ghost/versions/4.20.3/node_modules/bunyan/lib/bunyan.js:627:18)
[ghost-56f4c644f9-gps8f ghost]      at WriteStream.emit (events.js:400:28)
[ghost-56f4c644f9-gps8f ghost]      at emitErrorNT (internal/streams/destroy.js:106:8)
[ghost-56f4c644f9-gps8f ghost]      at emitErrorCloseNT (internal/streams/destroy.js:74:3)
[ghost-56f4c644f9-gps8f ghost]      at processTicksAndRejections (internal/process/task_queues.js:82:21) {
[ghost-56f4c644f9-gps8f ghost]    errno: -28,
[ghost-56f4c644f9-gps8f ghost]    code: 'ENOSPC',
[ghost-56f4c644f9-gps8f ghost]    syscall: 'write'
[ghost-56f4c644f9-gps8f ghost]  }
@wglambert wglambert added the Request Request for image modification or feature label Nov 24, 2021
@tianon
Copy link
Member

tianon commented Nov 24, 2021

I'm a bit confused -- from what I read in https://ghost.org/docs/config/#logging, log rotation should be already enabled by default? Did you customize the logging configuration?

@thedotedge
Copy link
Author

thedotedge commented Nov 25, 2021

That's the thing — I have not, so it should work. However, the actual outcome was a single file of 3.4G that has eaten up volume space.

By default Ghost keeps 10 log files and rotates every day. Rotation is enabled by default in production and disabled in development.

contrary to the default mentioned in the linked documentation, this image defaults to NODE_ENV=production (so development mode needs to be explicitly specified if desired)

apiVersion: apps/v1
kind: Deployment
metadata:
  name: ghost
  labels:
    app: ghost
    k10/injectKanisterSidecar: "true"
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ghost
      tier: web
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: ghost
        tier: web
    spec:
      containers:
        - name: ghost
          # https://github.com/TryGhost/Ghost/releases
          # https://hub.docker.com/_/ghost
          image: ghost:4.20.3
          ports:
            - containerPort: 2368
          env: 
            - name: url
              value: https://site.com/blog/
            - name: database__client
              value: mysql
            - name: database__connection__host
              value: ghost-mariadb
            - name: database__connection__user
              value: root
            - name: database__connection__password
              valueFrom:
                secretKeyRef:
                  name: ghost-mariadb
                  key: root-password
            - name: database__connection__database
              value: ghost
            - name: mail__transport
              value: "SMTP"
            - name: mail__options__host
              value: "smtp.sendgrid.net"
            - name: mail__options__port
              value: "587"
            - name: mail__options__auth__user
              value: "apikey"
            - name: mail__options__auth__pass
              valueFrom:
                secretKeyRef:
                  name: sendgrid
                  key: ghost-api-key
          volumeMounts:
            - mountPath: /var/lib/ghost/content
              name: ghost-content
      volumes:
        - name: ghost-content
          persistentVolumeClaim:
            claimName: ghost-content

@Torqu3Wr3nch
Copy link

Yeah, I posted about this a while back on the Ghost forums. Ghost's default configuration is definitely broken, even on a local install.

If you want to fix this temporarily, you can see how I fixed it here:
Save Disk Space By Setting Up Logrotate with Your Ghost Blog

Currently, I'm busy, but I can look into patching this myself in the image later.

@pascalandy
Copy link
Contributor

This is managed by the config file when you start ghost. Per example - https://github.com/firepress-org/ghostfire/blob/master/config.production.json#L25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Request Request for image modification or feature
Projects
None yet
Development

No branches or pull requests

5 participants