systemd installation, logrotate
This commit is contained in:
parent
63b0ce0a6e
commit
5ea0434cae
|
@ -17,6 +17,7 @@ start_logentries() {
|
|||
mkdir -p /home/${ADMIN_USERNAME}/logs
|
||||
touch /home/${ADMIN_USERNAME}/logs/dashboard.err
|
||||
touch /home/${ADMIN_USERNAME}/logs/dashboard.out
|
||||
touch /home/${ADMIN_USERNAME}/logs/parity.log
|
||||
touch /home/${ADMIN_USERNAME}/logs/netstats_daemon.err
|
||||
touch /home/${ADMIN_USERNAME}/logs/netstats_daemon.out
|
||||
touch /home/${ADMIN_USERNAME}/logs/explorer.err
|
||||
|
@ -41,6 +42,10 @@ destination = TestTestNets/${EXT_IP}
|
|||
path = /home/${ADMIN_USERNAME}/logs/dashboard.out
|
||||
destination = TestTestNets/${EXT_IP}
|
||||
|
||||
[parity_log]
|
||||
path = /home/${ADMIN_USERNAME}/logs/parity.log
|
||||
destination = TestTestNets/${EXT_IP}
|
||||
|
||||
[netstats_daemon_err]
|
||||
path = /home/${ADMIN_USERNAME}/logs/netstats_daemon.err
|
||||
destination = TestTestNets/${EXT_IP}
|
||||
|
@ -135,6 +140,7 @@ prepare_homedir() {
|
|||
cd "/home/${ADMIN_USERNAME}"
|
||||
echo "Now changed directory to: $(pwd)"
|
||||
mkdir -p logs
|
||||
mkdir -p logs/old
|
||||
echo "<===== prepare_homedir"
|
||||
}
|
||||
|
||||
|
@ -210,6 +216,11 @@ pull_image_and_configs() {
|
|||
curl -s -o "${GENESIS_JSON}" "${GENESIS_REPO_LOC}"
|
||||
curl -s -O "${INSTALL_CONFIG_REPO}/${NODE_TOML}"
|
||||
sed -i "/\[network\]/a nat=\"extip:${EXT_IP}\"" ${NODE_TOML}
|
||||
cat >> ${NODE_TOML} <<EOF
|
||||
[misc]
|
||||
logging="engine=trace,network=trace,discovery=trace"
|
||||
log_file = "/home/${ADMIN_USERNAME}/logs/parity.log"
|
||||
EOF
|
||||
echo "${OWNER_KEYPASS}" > "${NODE_PWD}"
|
||||
mkdir -p parity/keys/OraclesPoA
|
||||
echo ${OWNER_KEYFILE} | base64 -d > parity/keys/OraclesPoA/owner.key
|
||||
|
@ -327,6 +338,63 @@ EOF
|
|||
echo "<===== install_netstats"
|
||||
}
|
||||
|
||||
install_netstats_via_systemd() {
|
||||
echo "=====> install_netstats_via_systemd"
|
||||
git clone https://github.com/oraclesorg/eth-net-intelligence-api
|
||||
cd eth-net-intelligence-api
|
||||
#sed -i '/"web3"/c "web3": "0.19.x",' package.json
|
||||
npm install
|
||||
sudo npm install pm2 -g
|
||||
|
||||
cat > app.json << EOL
|
||||
[
|
||||
{
|
||||
"name" : "netstats_daemon",
|
||||
"script" : "app.js",
|
||||
"log_date_format" : "YYYY-MM-DD HH:mm:SS Z",
|
||||
"error_file" : "/home/${ADMIN_USERNAME}/logs/netstats_daemon.err",
|
||||
"out_file" : "/home/${ADMIN_USERNAME}/logs/netstats_daemon.out",
|
||||
"merge_logs" : false,
|
||||
"watch" : false,
|
||||
"max_restarts" : 100,
|
||||
"exec_interpreter" : "node",
|
||||
"exec_mode" : "fork_mode",
|
||||
"env":
|
||||
{
|
||||
"NODE_ENV" : "production",
|
||||
"RPC_HOST" : "localhost",
|
||||
"RPC_PORT" : "8545",
|
||||
"LISTENING_PORT" : "30300",
|
||||
"INSTANCE_NAME" : "${NODE_FULLNAME}",
|
||||
"CONTACT_DETAILS" : "${NODE_ADMIN_EMAIL}",
|
||||
"WS_SERVER" : "http://localhost:3000",
|
||||
"WS_SECRET" : "${NETSTATS_SECRET}",
|
||||
"VERBOSITY" : 2
|
||||
}
|
||||
}
|
||||
]
|
||||
EOL
|
||||
cd ..
|
||||
sudo bash -c "cat > /etc/systemd/system/oracles-netstats.service <<EOF
|
||||
[Unit]
|
||||
Description=oracles netstats service
|
||||
After=network.target
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=true
|
||||
User=${ADMIN_USERNAME}
|
||||
Group=${ADMIN_USERNAME}
|
||||
Environment=MYVAR=myval
|
||||
WorkingDirectory=/home/${ADMIN_USERNAME}/eth-net-intelligence-api
|
||||
ExecStart=/usr/bin/pm2 startOrRestart app.json
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF"
|
||||
sudo systemctl enable oracles-netstats
|
||||
sudo systemctl start oracles-netstats
|
||||
echo "<===== install_netstats_via_systemd"
|
||||
}
|
||||
|
||||
install_chain_explorer() {
|
||||
echo "=====> install_chain_explorer"
|
||||
git clone https://github.com/oraclesorg/chain-explorer
|
||||
|
@ -424,6 +492,29 @@ EOF
|
|||
echo "<===== use_deb"
|
||||
}
|
||||
|
||||
use_deb_via_systemd() {
|
||||
echo "=====> use_deb_via_systemd"
|
||||
curl -LO 'http://parity-downloads-mirror.parity.io/v1.7.0/x86_64-unknown-linux-gnu/parity_1.7.0_amd64.deb'
|
||||
sudo dpkg -i parity_1.7.0_amd64.deb
|
||||
|
||||
sudo bash -c "cat > /etc/systemd/system/oracles-parity.service <<EOF
|
||||
[Unit]
|
||||
Description=oracles parity service
|
||||
After=network.target
|
||||
[Service]
|
||||
User=${ADMIN_USERNAME}
|
||||
Group=${ADMIN_USERNAME}
|
||||
WorkingDirectory=/home/${ADMIN_USERNAME}
|
||||
ExecStart=/usr/bin/parity --config=node.toml --ui-no-validation
|
||||
Restart=always
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF"
|
||||
sudo systemctl enable oracles-parity
|
||||
sudo systemctl start oracles-parity
|
||||
echo "<===== use_deb_via_systemd"
|
||||
}
|
||||
|
||||
use_bin() {
|
||||
echo "=====> use_bin"
|
||||
sudo apt-get install -y dtach unzip
|
||||
|
@ -478,6 +569,33 @@ EOF"
|
|||
echo "<===== setup_autoupdate"
|
||||
}
|
||||
|
||||
configure_logrotate() {
|
||||
echo "=====> configure_logrotate"
|
||||
|
||||
sudo bash -c "cat > /etc/logrotate.d/oracles.conf << EOF
|
||||
/home/${ADMIN_USERNAME}/logs/*.log {
|
||||
rotate 10
|
||||
size 200M
|
||||
missingok
|
||||
compress
|
||||
copytruncate
|
||||
dateext
|
||||
dateformat %Y-%m-%d-%s
|
||||
olddir old
|
||||
}
|
||||
/home/${ADMIN_USERNAME}/.pm2/pm2.log {
|
||||
su ${ADMIN_USERNAME} ${ADMIN_USERNAME}
|
||||
rotate 10
|
||||
size 200M
|
||||
missingok
|
||||
compress
|
||||
copytruncate
|
||||
dateext
|
||||
dateformat %Y-%m-%d-%s
|
||||
}"
|
||||
echo "<===== configure_logrotate"
|
||||
}
|
||||
|
||||
download_initial_keys_script() {
|
||||
echo "=====> download_initial_keys_script"
|
||||
git clone https://github.com/oraclesorg/oracles-initial-keys
|
||||
|
@ -503,16 +621,20 @@ main () {
|
|||
clone_dapps
|
||||
|
||||
#start_docker
|
||||
use_deb
|
||||
#use_deb
|
||||
use_deb_via_systemd
|
||||
#use_bin
|
||||
#compile_source
|
||||
|
||||
#setup_autoupdate
|
||||
|
||||
install_dashboard
|
||||
install_netstats
|
||||
#install_netstats
|
||||
install_netstats_via_systemd
|
||||
install_chain_explorer
|
||||
|
||||
configure_logrotate
|
||||
|
||||
download_initial_keys_script
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue