0

I am setting a CI/CD using AWS CodeBuild. But I got a problem that can't start the redis system.

[Container] 2023/06/27 09:16:34 Running command sudo systemctl start redis6
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

[Container] 2023/06/27 09:16:34 Command did not exit successfully sudo systemctl start redis6 exit status 1
[Container] 2023/06/27 09:16:34 Phase complete: INSTALL State: FAILED
[Container] 2023/06/27 09:16:34 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: sudo systemctl start redis6. Reason: exit status 

Here is my setup:

version: 0.2

phases:
    install:
        commands:
            - echo check AWS version...
            - cat /etc/image-id
            - sudo yum update -y
            - sudo dnf install -y redis6
            - sudo systemctl start redis6
            - sudo systemctl enable redis6
            - sudo systemctl is-enabled redis6
    pre_build:
        commands:
            - echo check node version...
            - node -v
            - echo set config...
            - npm config set registry http://registry.npmjs.org/
            - echo Install packages...
            - npm install
    build:
        commands:
            - echo Build started on `date`
             .......
    post_build:
        commands:
            - echo Build completed on `date`
            - echo Removing node modules folder...
            - rm -rf node_modules/
artifacts:
    files:
        - '**/*'
    base-directory: '.'
James Z
  • 12,209
  • 10
  • 24
  • 44
dacoten
  • 115
  • 2
  • 12
  • 2
    This is not the full answer, just an explanation: the PID 1 is an init script which starts everything else. you try to use the command "systemctl" which works together with a specific type of bootstrap&management system systemd. You don't have it. You can probably run redis6 from your command line, but you need to run it as a deamon, otherwise you cannot continue the execution, there are multiple ways how to do it, but in general https://stackoverflow.com/questions/3430330/best-way-to-make-a-shell-script-daemon it works like this. Is it a good idea what you are trying to do? I don't know... – petrch Jun 27 '23 at 10:14

0 Answers0