Skip to content

Instantly share code, notes, and snippets.

@TheRatG
Last active January 24, 2023 05:08
Show Gist options
  • Select an option

  • Save TheRatG/71d69cdd8ba94c0fa74cd3e53020bbc0 to your computer and use it in GitHub Desktop.

Select an option

Save TheRatG/71d69cdd8ba94c0fa74cd3e53020bbc0 to your computer and use it in GitHub Desktop.
Prepare platform

bash

Add into begining of file ~/.bashrc

[ -d ~/bin ] && PATH=~/bin:$PATH

mysql

A mysql and a mysqldump without user:passwod

# ~/.my.cnf
[mysql]
user=<username>
password=<password>

[mysqldump]
user=<username>
password=<password>

[clientfront]
user=<username_front>
password=<password_front>

[mysqldumpfront]
user=<username_front>
password=<password_front>

[clientback]
user=<username_back>
password=<password_back>
host=<host>
port=<port>

[mysqldumpback]
user=<username_back>
password=<password_back>
host=<host>
port=<port>
mysql # default connection
mysql --defaults-group-suffix=front #front connection

node js locally

Create file for example ~/scripts/install_node.sh

#!/usr/bin/env bash

VERSION=v6.11.3

cd ~/
if [ ! -d ~/node ]; then mkdir ~/node; fi;
cd ~/node
if [ ! -f node-${VERSION}-linux-x64.tar.gz ]; then
    wget https://nodejs.org/download/release/${VERSION}/node-${VERSION}-linux-x64.tar.gz;
    tar zxf node-${VERSION}-linux-x64.tar.gz;
fi;
[ -L current ] && rm current
ln -s node-${VERSION}-linux-x64 current
cd ~/
if [ ! -d ~/bin ]; then mkdir ~/bin; fi;
cd ~/bin
[ -L node ] && rm node
ln -s ~/node/current/bin/node node
[ -L npm ] && rm npm
ln -s ~/node/current/bin/npm npm

supervisor

Create file for example ~/scripts/setup_supervisor.sh

#!/usr/bin/env bash

if [ ! -d ${HOME}/supervisor ]; then mkdir ${HOME}/supervisor; fi;
if [ ! -d ${HOME}/supervisor/conf.d ]; then mkdir ${HOME}/supervisor/conf.d; fi;
if [ ! -d ${HOME}/supervisor/logs ]; then mkdir ${HOME}/supervisor/logs; fi;

cd  ~/supervisor;
touch console && chmod +x console;

echo -e '#!/bin/bash' > console;
echo -e "supervisorctl -c ${HOME}/supervisor/supervisord.conf" >> console;

cat > supervisord.conf << EOF
; supervisor config file

[unix_http_server]
file=$(echo -n ${HOME})/supervisor/$(whoami).sock   ; (the path to the socket file)
chmod=0700                       ; sockef file mode (default 0700)

[supervisord]
logfile=$(echo -n ${HOME})/supervisor/logs/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=$(echo -n ${HOME})/supervisor/supervisord.pid ; (do not change this filename, because monit)
childlogdir=$(echo -n ${HOME})/supervisor/logs            ; ('AUTO' child log dir, default $TEMP)
minprocs=10

; the below 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: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix://$(echo -n ${HOME})/supervisor/$(whoami).sock ; use a unix:// URL  for a unix socket

; The [include] section can just contain the "files" setting.  This
; setting can list multiple files (separated by whitespace or
; newlines).  It can also contain wildcards.  The filenames are
; interpreted as relative to this file.  Included files *cannot*
; include files themselves.

[include]
files = $(echo -n ${HOME})/supervisor/conf.d/*.conf
EOF

touch $(echo -n ${HOME})/supervisor/conf.d/supervisor.conf

cat > README.md << EOF
# Supervisor

Run daemon

/usr/bin/python /usr/bin/supervisord -c $(echo -n ${HOME})/supervisor/supervisord.conf

Reload

supervisorctl -c $(echo -n ${HOME})/supervisor/supervisord.conf reload

EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment