3.5 KiB
3.5 KiB
AITBC Systemd Git Workflow Skill
Description
Expert skill for managing systemd service files using proper git workflow instead of scp operations. Ensures systemd configurations are always synchronized via git repository rather than direct file copying.
Core Principles
Git-Tracked Files Only
- All systemd service files must be edited in
/opt/aitbc/systemd/(git-tracked directory) - NEVER edit files directly in
/etc/systemd/system/ - NEVER use scp to copy systemd files between nodes
Symbolic Link Architecture
/etc/systemd/system/aitbc-*.service->/opt/aitbc/systemd/aitbc-*.service- Symlinks ensure active systemd files always match repository
- Changes in repository automatically reflected in active configuration
Standard Workflow
Local Changes
- Edit files in
/opt/aitbc/systemd/ - Commit changes:
git add systemd/ && git commit -m "description" - Push to gitea:
git push
Remote Sync (aitbc1)
- Pull changes:
git pull - Create/update symlinks:
/opt/aitbc/scripts/utils/link-systemd.sh - Reload systemd:
systemctl daemon-reload - Restart affected services:
systemctl restart aitbc-*
Available Scripts
link-systemd.sh
- Location:
/opt/aitbc/scripts/utils/link-systemd.sh - Purpose: Creates symbolic links from
/etc/systemd/system/to/opt/aitbc/systemd/ - Usage:
/opt/aitbc/scripts/utils/link-systemd.sh - Benefits: Automatic sync, no manual file copying needed
sync-systemd.sh
- Location:
/opt/aitbc/scripts/sync/sync-systemd.sh - Purpose: Copies repository files to active systemd (alternative to symlinks)
- Usage:
/opt/aitbc/scripts/sync/sync-systemd.sh - Note: Prefer link-systemd.sh for automatic sync
Common Issues
Git Conflicts on Remote Nodes
Symptom: git pull fails with "local changes would be overwritten"
Resolution:
- Discard local changes:
git reset --hard HEAD - Pull changes:
git pull - Re-run link-systemd.sh:
/opt/aitbc/scripts/utils/link-systemd.sh
Broken Symlinks
Symptom: Systemd service fails to load or uses old configuration
Resolution:
- Verify symlinks:
ls -la /etc/systemd/system/aitbc-* - Re-create symlinks:
/opt/aitbc/scripts/utils/link-systemd.sh - Reload systemd:
systemctl daemon-reload
SCP Usage Warning
Symptom: Direct scp to /etc/systemd/system/ breaks symlinks
Resolution:
- Never use scp to
/etc/systemd/system/ - Always use git workflow
- If scp was used, restore proper symlinks with link-systemd.sh
Verification Commands
Check Symlink Status
ls -la /etc/systemd/system/aitbc-*
readlink /etc/systemd/system/aitbc-blockchain-node.service
Verify Git Status
git status
git diff systemd/
Check Service Configuration
systemctl cat aitbc-blockchain-node.service
Best Practices
- Always edit in git-tracked directory:
/opt/aitbc/systemd/ - Commit before pushing: Ensure changes are properly committed
- Pull before link-systemd.sh: Ensure repository is up-to-date
- Test locally first: Verify changes work before syncing to remote
- Document changes: Use descriptive commit messages
- Monitor logs: Check service logs after changes
- Run as root: No sudo needed - we are root on both nodes
Memory Reference
See memory entry systemd-git-workflow for detailed workflow documentation (no sudo needed - we are root on both nodes).
Related Skills
- aitbc-basic-operations-skill: Basic git operations
- aitbc-system-architect: System architecture understanding
- blockchain-troubleshoot-recovery: Service troubleshooting