Giter Club home page Giter Club logo

Comments (3)

CoderPlusFromNowhere avatar CoderPlusFromNowhere commented on August 27, 2024 5

There is a lot of errors in Amazon Linux 2023.

nodejs cant install
php-redis cant install
supervisor cant install

from laravel-aws-eb.

Rorymercer avatar Rorymercer commented on August 27, 2024 4

Couple of workarounds that worked for me, might be helpful for others on Amazon Linux 2023

Predis - Install via PECL

.platform/hooks/prebuild/install_phpredis.sh

#!/bin/sh

sudo pecl channel-update pecl.php.net
sudo pecl upgrade redis  #install redis with default configuration options to command line

#Move the redis config line automatically added to its own file, respecting any config there from previous deployments
sed -i -e '/extension="redis.so"/d' /etc/php.ini
sudo touch /etc/php.d/41-redis.ini
grep -qxF 'extension="redis.so"' /etc/php.d/41-redis.ini || echo 'extension="redis.so"' | sudo tee -a /etc/php.d/41-redis.ini

Supervisor

A bit tricker now that amazon-linux-extras has been removed. Installed via pip and then kept alive with systemd and an additional two configuration files (one for Supervisor one for Systemd)

.platform/hooks/prebuild/install_phpredis.sh

#AWS2023 PHP build Has python 3 without pip, install this first:
sudo python3 -m ensurepip --upgrade

#Install supervisor
sudo pip3 install supervisor

#Copy the configuration file
sudo cp .platform/files/supervisord.conf /etc/supervisord.conf

#Copy and enable the systemd service file
sudo cp .platform/files/supervisord.service /etc/systemd/system/supervisord.service
sudo systemctl daemon-reload

sudo mkdir /etc/supervisord
sudo cp .platform/files/supervisor.ini /etc/supervisord/laravel.ini

sudo systemctl enable supervisord
sudo systemctl start supervisord

sudo supervisorctl reread

sudo supervisorctl update

.platform/files/supervisord.conf

; Sample supervisor config file.
;
; For more information on the config file, please see:
; http://supervisord.org/configuration.html
;
; Notes:
;  - Shell expansion ("~" or "$HOME") is not supported.  Environment
;    variables can be expanded using this syntax: "%(ENV_HOME)s".
;  - Quotes around values are not supported, except in the case of
;    the environment= options as shown below.
;  - Comments must have a leading space: "a=b ;comment" not "a=b;comment".
;  - Command will be truncated if it looks like a config file comment, e.g.
;    "command=bash -c 'foo ; bar'" will truncate to "command=bash -c 'foo ".
;
; Warning:
;  Paths throughout this example file use /tmp because it is available on most
;  systems.  You will likely need to change these to locations more appropriate
;  for your system.  Some systems periodically delete older files in /tmp.
;  Notably, if the socket file defined in the [unix_http_server] section below
;  is deleted, supervisorctl will be unable to connect to supervisord.

[unix_http_server]
file=/var/supervisor.sock   ; the path to the socket file
;chmod=0700                 ; socket file mode (default 0700)
;chown=nobody:nogroup       ; socket file uid:gid owner
;username=user              ; default is no username (open server)
;password=123               ; default is no password (open server)

; Security Warning:
;  The inet HTTP server is not enabled by default.  The inet HTTP server is
;  enabled by uncommenting the [inet_http_server] section below.  The inet
;  HTTP server is intended for use within a trusted environment only.  It
;  should only be bound to localhost or only accessible from within an
;  isolated, trusted network.  The inet HTTP server does not support any
;  form of encryption.  The inet HTTP server does not use authentication
;  by default (see the username= and password= options to add authentication).
;  Never expose the inet HTTP server to the public internet.

;[inet_http_server]         ; inet (TCP) server disabled by default
;port=127.0.0.1:9001        ; ip_address:port specifier, *:port for all iface
;username=user              ; default is no username (open server)
;password=123               ; default is no password (open server)

[supervisord]
logfile=/var/log/supervisord.log ; main log file; default $CWD/supervisord.log
logfile_maxbytes=50MB        ; max main logfile bytes b4 rotation; default 50MB
logfile_backups=10           ; # of main logfile backups; 0 means none, default 10
loglevel=info                ; log level; default info; others: debug,warn,trace
pidfile=/var/supervisord.pid ; supervisord pidfile; default supervisord.pid
nodaemon=false               ; start in foreground if true; default false
silent=false                 ; no logs to stdout if true; default false
minfds=1024                  ; min. avail startup file descriptors; default 1024
minprocs=200                 ; min. avail process descriptors;default 200
;umask=022                   ; process file creation umask; default 022
;user=supervisord            ; setuid to this UNIX account at startup; recommended if root
;identifier=supervisor       ; supervisord identifier, default is 'supervisor'
;directory=/tmp              ; default is not to cd during start
;nocleanup=true              ; don't clean up tempfiles at start; default false
;childlogdir=/tmp            ; 'AUTO' child log dir, default $TEMP
;environment=KEY="value"     ; key value pairs to add to environment
;strip_ansi=false            ; strip ansi escape codes in logs; def. false

; The rpcinterface:supervisor section must remain in the config file for
; RPC (supervisorctl/web interface) to work.  Additional interfaces may be
; added by defining them in separate [rpcinterface:x] sections.

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

; The supervisorctl section configures how supervisorctl will connect to
; supervisord.  configure it match the settings in either the unix_http_server
; or inet_http_server section.

[supervisorctl]
serverurl=unix:///var/supervisor.sock ; use a unix:// URL  for a unix socket
;serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
;username=chris              ; should be same as in [*_http_server] if set
;password=123                ; should be same as in [*_http_server] if set
;prompt=mysupervisor         ; cmd line prompt (default "supervisor")
;history_file=~/.sc_history  ; use readline history if available

[include]
files = supervisord/*.ini

.platform/files/supervisord.service

[Unit]
Description=Supervisor process control system for UNIX
Documentation=http://supervisord.org
After=network.target

[Service]
#Uncomment the line below if you want to run it as a daemon
#Type=forking
ExecStart=/usr/local/bin/supervisord -n -c /etc/supervisord.conf
ExecStop=/usr/local/bin/supervisorctl $OPTIONS shutdown
ExecReload=/usr/local/bin/supervisorctl $OPTIONS reload
KillMode=process
Restart=on-failure
RestartSec=20s

[Install]
WantedBy=multi-user.target

I've used sudo throughout for consistency with these files, but I think they run as root by default on Amazon Linux.

Hope it's helpful!

from laravel-aws-eb.

WalrusSoup avatar WalrusSoup commented on August 27, 2024

Any risk in using systemd to do this since its already on-rack? Currently playing with these configurations to hit a sweet spot:

/.platform/files/app.service

[Unit]
Description=Queue Worker
After=network.target

[Service]
User=webapp
WorkingDirectory=/var/app/current
ExecStart=php artisan queue:work
Restart=always
RestartSec=5s

[Install]
WantedBy=multi-user.target

/.platform/hooks/prebuild/configure_systemd.sh

sudo cp .platform/config/app.service /etc/systemd/system/[email protected]
sudo systemctl daemon-reload
// start 2 queue workers
sudo systemctl start [email protected]
sudo systemctl start [email protected]
sudo systemctl enable [email protected]
sudo systemctl enable [email protected]

.platform/hooks/postdeploy/restart_services.sh

sudo systemctl daemon-reload
sudo systemctl restart [email protected]
sudo systemctl restart [email protected]

Only issue is if the queue changes, you'd need to basically dump all the services and re-add them since it doesn't seem to just scan them at is.

Would love if someone familiar with systemd could chime in

from laravel-aws-eb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.