PikaFileService is a file synchronization service that can be run as a systemd service with root permissions.
pikafileservice.service- Systemd service definitioninstall_service.sh- Service installation scriptuninstall_service.sh- Service removal scriptmanage_service.sh- Service management helperMakefile- Build and service management targets
# Build the binary and install as systemd service
make installOr manually:
# Build the binary
go build -o pikafileservice Main.go
# Install service (requires sudo)
sudo ./install_service.sh# Start the service
sudo systemctl start pikafileservice
# Check status
sudo systemctl status pikafileservice# Follow logs in real-time
sudo journalctl -u pikafileservice -f
# View all logs
sudo journalctl -u pikafileservice# Start service
./manage_service.sh start
# Stop service
./manage_service.sh stop
# Restart service
./manage_service.sh restart
# Check status
./manage_service.sh status
# Follow logs
./manage_service.sh logs
# Enable auto-start on boot
./manage_service.sh enable
# Disable auto-start
./manage_service.sh disable# Service management
make service-start
make service-stop
make service-restart
make service-status
make service-logs
make service-enable
make service-disable
# Complete installation
make install
# Complete removal
make uninstall# Basic service control
sudo systemctl start pikafileservice
sudo systemctl stop pikafileservice
sudo systemctl restart pikafileservice
sudo systemctl status pikafileservice
# Auto-start configuration
sudo systemctl enable pikafileservice
sudo systemctl disable pikafileservice
# View logs
sudo journalctl -u pikafileservice -f- Runs as root - Has full filesystem access as required
- Network dependency - Waits for network.target before starting
- Auto-restart - Automatically restarts if it crashes
- Resource limits - Configurable file handle and process limits
- Security - Uses systemd security features where possible
- Logging - Logs to both systemd journal and application log file
- Binary:
/opt/pikafileservice/pikafileservice - Config:
/opt/pikafileservice/config.json - Logs:
/var/log/pikafileservice/pikafileservice.log - Service:
/etc/systemd/system/pikafileservice.service
The service uses the configuration file at /opt/pikafileservice/config.json. Your current configuration will be copied during installation:
{
"folders": [
"/home/ofca/sync"
],
"workDir": "/home/ofca/sync",
"dstPath": "/mnt/public"
}You can modify this file after installation and restart the service to apply changes.
sudo systemctl status pikafileservice# Last 50 lines
sudo journalctl -u pikafileservice -n 50
# Follow logs
sudo journalctl -u pikafileservice -f
# Application log file
sudo tail -f /var/log/pikafileservice/pikafileservice.logTo run with debug output, temporarily modify the service:
sudo systemctl edit pikafileserviceAdd this content:
[Service]
ExecStart=
ExecStart=/opt/pikafileservice/pikafileservice -c /opt/pikafileservice/config.json -l /var/log/pikafileservice/pikafileservice.log -dThen restart:
sudo systemctl daemon-reload
sudo systemctl restart pikafileservice- Permission denied errors: Ensure the service is running as root
- Configuration errors: Check
/opt/pikafileservice/config.jsonsyntax - Network issues: Verify network.target is loaded before service starts
- File access issues: Check that source and destination paths exist and are accessible
# Complete removal
make uninstall
# Or manually
sudo ./uninstall_service.shThis will:
- Stop and disable the service
- Remove the systemd service file
- Optionally remove installation and log directories
# Standard build
make build
# Static binary for deployment
make build-release
# Clean build artifacts
make clean# Run tests
make test
# Run manually for testing
go run Main.go -c config.json -d