-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Install.sh should install a service file #3811
Labels
request/needs-discussion
Request: Requires further discussion to proceed
Comments
what do you want the service file to do ? [Unit]
Description=Bacalhau Daemon
After=network-online.target
Wants=network-online.target systemd-networkd-wait-online.service
[Service]
Environment="LOG_TYPE=json"
Environment="BACALHAU_DIR=/data"
Environment="BACALHAU_ENVIRONMENT=local"
Restart=always
RestartSec=5s
ExecStart=bacalhau serve ${args}
[Install]
WantedBy=multi-user.target [Unit]
Description=Startup Script
After=network-online.target
Wants=network-online.target systemd-networkd-wait-online.service
[Service]
ExecStart=/usr/local/bin/startup-script.sh
Restart=on-failure
RestartSec=10s
[Install]
WantedBy=multi-user.target #! /bin/bash
echo "Startup script is running as user: $(whoami)"
CONFIG_FILE="/etc/config.yaml"
echo "Fetching node type..."
NODE_TYPE=$(curl -f http://metadata.google.internal/computeMetadata/v1/instance/attributes/node_type -H "Metadata-Flavor: Google")
CURL_STATUS=$?
if [ $CURL_STATUS -ne 0 ]; then
echo "Error fetching NODE_TYPE. Exiting..."
exit 1
fi
echo "Node Type: $NODE_TYPE"
if [ "$NODE_TYPE" = "requester" ]; then
echo "Node type is requester."
if [ ! -f $CONFIG_FILE ]; then
sudo cp /etc/requester_config.yaml $CONFIG_FILE
fi
else
echo "Node type is not requester. Fetching requester IP..."
REQUESTER_IP=$(curl -s -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/attributes/requester_ip")
echo "Requester IP: $REQUESTER_IP"
if [ ! -f $CONFIG_FILE ]; then
sudo cp /etc/compute_config.yaml $CONFIG_FILE
sed -i "s/\${requester_ip}/$REQUESTER_IP/g" $CONFIG_FILE
fi
fi
if [ ! -d /data ]; then
sudo mkdir -p /data
sudo chmod 0700 /data
echo "/data directory created."
else
echo "/data directory already exists. No need to create."
fi
if [ ! -f /data/config.yaml ]; then
echo "Moving configuration file..."
sudo mv "$CONFIG_FILE" /data/config.yaml
else
echo "Configuration file already exists, not moving."
fi
echo "Checking and moving service files..."
if [ ! -f /etc/systemd/system/bacalhau.service ]; then
sudo mv /etc/bacalhau.service /etc/systemd/system/bacalhau.service
else
echo "Service file already exists in target location, not moving."
fi
echo "Reloading systemctl daemon..."
systemctl daemon-reload
echo "Handling Docker service..."
systemctl enable docker
systemctl restart docker
echo "Enabling bacalhau service..."
systemctl enable bacalhau.service
systemctl restart bacalhau.service |
wdbaruni
added
the
request/needs-discussion
Request: Requires further discussion to proceed
label
May 13, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That runs Bacalhau using systemd (or equivalent)
The text was updated successfully, but these errors were encountered: