diff --git a/memo/git-hook.md b/memo/git-hook.md new file mode 100644 index 0000000..fa230d8 --- /dev/null +++ b/memo/git-hook.md @@ -0,0 +1,33 @@ +# Automate update via Git Hook + +1. Navigate to the bare repository: +```bash +cd ~/git/asobi.git/hooks +``` + +2. Create `post-receive` Hook: +```bash +nano post-receive +``` + +3. Add script you want to run: +```bash +#!/bin/bash + +# Deployment directory +DEPLOY_DIR="/home/nik/repo/asobi" + +# Navigate to the deployment directory +cd $DEPLOY_DIR + +# Pull the latest changes +git pull origin main + +# Restart the service +sudo systemctl restart asobi-web.service +``` + +4. Make the hook executable: +``` +chmod +x post-receive +``` \ No newline at end of file diff --git a/memo/make-systemd.md b/memo/make-systemd.md new file mode 100644 index 0000000..7bd3fe1 --- /dev/null +++ b/memo/make-systemd.md @@ -0,0 +1,45 @@ +1. Open new service file: +``` +sudo nano /etc/systemd/system/.service +``` + +2. Content +``` +[Unit] +Description=Page Host Service +After=network.target + +[Service] +User=your_username +WorkingDirectory=/home/your_username/repo/asobi +Environment=PYENV_ROOT=/home/your_username/.pyenv +ExecStart=/bin/bash -c "source $PYENV_ROOT/bin/pyenv && pyenv activate pyenv && python page_host.py" +Restart=always +RestartSec=5 + +[Install] +WantedBy=multi-user.target +``` + +3. Reload systemd, enable service: +``` +sudo systemctl daemon-reload +sudo systemctl enable .service +sudo systemctl start .service +``` + +4. Check status: +``` +sudo systemctl status .service +journalctl -u .service +``` + +5. Test reboot: +``` +sudo reboot +``` + +Check status +``` +sudo systemctl status page_host.service +``` \ No newline at end of file