deploy
This commit is contained in:
parent
b522eb7da3
commit
4017e8ab5c
10 changed files with 426 additions and 0 deletions
93
scripts/start_services.sh
Executable file
93
scripts/start_services.sh
Executable file
|
|
@ -0,0 +1,93 @@
|
|||
#!/bin/bash
|
||||
|
||||
start_services() {
|
||||
USER_HOME=$(eval echo ~$(whoami))
|
||||
if [ "$OS" = "Linux" ]; then
|
||||
if [ "$SYSTEMCTL_AVAILABLE" = true ]; then
|
||||
sudo bash -c "cat > /etc/systemd/system/lnd.service <<EOF
|
||||
[Unit]
|
||||
Description=LND Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=${USER_HOME}/lnd/lnd
|
||||
User=$(whoami)
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF"
|
||||
|
||||
sudo bash -c "cat > /etc/systemd/system/lightning_pub.service <<EOF
|
||||
[Unit]
|
||||
Description=Lightning.Pub Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/bin/bash -c 'source ${NVM_DIR}/nvm.sh && npm start'
|
||||
WorkingDirectory=${USER_HOME}/lightning_pub
|
||||
User=$(whoami)
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF"
|
||||
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable lnd
|
||||
sudo systemctl enable lightning_pub
|
||||
|
||||
log "${PRIMARY_COLOR}Starting${RESET_COLOR} ${SECONDARY_COLOR}LND${RESET_COLOR} service..."
|
||||
sudo systemctl start lnd &
|
||||
lnd_pid=$!
|
||||
wait $lnd_pid
|
||||
if systemctl is-active --quiet lnd; then
|
||||
log "${SECONDARY_COLOR}LND${RESET_COLOR} started successfully using systemd."
|
||||
else
|
||||
log "Failed to start ${SECONDARY_COLOR}LND${RESET_COLOR} using systemd."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log "Giving ${SECONDARY_COLOR}LND${RESET_COLOR} a few seconds to start before starting ${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR}..."
|
||||
sleep 10
|
||||
|
||||
log "${PRIMARY_COLOR}Starting${RESET_COLOR} ${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR} service..."
|
||||
sudo systemctl start lightning_pub &
|
||||
lightning_pub_pid=$!
|
||||
wait $lightning_pub_pid
|
||||
if systemctl is-active --quiet lightning_pub; then
|
||||
log "${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR} started successfully using systemd."
|
||||
else
|
||||
log "Failed to start ${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR} using systemd."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
create_start_script
|
||||
log "systemctl not available. Created start.sh. Please use this script to start the services manually."
|
||||
fi
|
||||
elif [ "$OS" = "Mac" ]; then
|
||||
log "macOS detected. Please configure launchd manually to start ${SECONDARY_COLOR}LND${RESET_COLOR} and ${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR} at startup."
|
||||
create_start_script
|
||||
elif [ "$OS" = "Cygwin" ] || [ "$OS" = "MinGw" ]; then
|
||||
log "Windows detected. Please configure your startup scripts manually to start ${SECONDARY_COLOR}LND${RESET_COLOR} and ${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR} at startup."
|
||||
create_start_script
|
||||
else
|
||||
log "Unsupported OS detected. Please configure your startup scripts manually."
|
||||
create_start_script
|
||||
fi
|
||||
}
|
||||
|
||||
create_start_script() {
|
||||
cat <<EOF > start.sh
|
||||
#!/bin/bash
|
||||
${USER_HOME}/lnd/lnd &
|
||||
LND_PID=\$!
|
||||
sleep 10
|
||||
npm start &
|
||||
NODE_PID=\$!
|
||||
wait \$LND_PID
|
||||
wait \$NODE_PID
|
||||
EOF
|
||||
chmod +x start.sh
|
||||
log "systemctl not available. Created start.sh. Please use this script to start the services manually."
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue