2.1 KiB
2.1 KiB
name, description
| name | description |
|---|---|
| systemd-vite-dev-service | Configure systemd service for Vite development server with external network exposure. Use when setting up persistent Vite dev servers that need to survive SSH disconnections and accept connections from external IPs. |
Systemd Vite Dev Service
Configure Vite development server as a systemd service for persistent, externally-accessible development environments.
When to Use
- Setting up Vite dev server that persists after SSH disconnect
- Need external access to dev server (not just localhost)
- Creating standardized development environment across reboots
- Managing multiple frontend projects with systemd
Key Configuration
ExecStart Pattern
ExecStart=/bin/bash -c "cd /path/to/project && npm run dev -- --host 0.0.0.0 --port <PORT>"
Required flags:
--host 0.0.0.0- Bind to all interfaces (external access)--port <PORT>- Explicit port assignment
Service File Template
[Unit]
Description=Project Frontend Dev Server
After=network.target
[Service]
Type=simple
User=ubuntu
WorkingDirectory=/home/ubuntu/nanocode/project
Environment=NODE_ENV=development
ExecStart=/bin/bash -c "cd /home/ubuntu/nanocode/project && npm run dev -- --host 0.0.0.0 --port 10002"
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
Commands
# Install and start
sudo cp project-frontend.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable project-frontend
sudo systemctl start project-frontend
# Check status
sudo systemctl status project-frontend
sudo journalctl -u project-frontend -f
# Restart after code changes
sudo systemctl restart project-frontend
Port Planning Reference
| Project | Frontend Port | Backend Port |
|---|---|---|
| Feidian Health | 10002 | 10003 |
| fumamxCRM | 10000 | 10001 |
| personal-blog | 8888 | 8889 |
Output Format
Provide:
- Complete
.servicefile content - Installation commands
- Verification commands (status + journalctl)
- Port conflict check command:
sudo netstat -tlnp | grep <PORT>