fixed .env use

This commit is contained in:
kilyabin
2025-11-18 04:16:52 +04:00
parent 327f143a29
commit b5f902a13f
3 changed files with 24 additions and 10 deletions

View File

@@ -122,9 +122,14 @@ The installation script will:
1. Edit environment variables: 1. Edit environment variables:
```bash ```bash
sudo nano /opt/kspguti-schedule/.env.production sudo nano /opt/kspguti-schedule/.env
``` ```
The installation script will:
- Copy `.env` file from source directory if it exists
- Preserve existing `.env` in installation directory if it already exists
- Create `.env` from `.env.production.example` if no `.env` file is found
2. Update systemd service if needed: 2. Update systemd service if needed:
```bash ```bash
sudo nano /etc/systemd/system/kspguti-schedule.service sudo nano /etc/systemd/system/kspguti-schedule.service
@@ -178,7 +183,7 @@ sudo journalctl -u kspguti-schedule -f
**Environment variables:** **Environment variables:**
See `.env.production.example` for available options: See `.env.production.example` or `.example.env` for available options. The application uses `.env` file in production:
- `PROXY_URL` - URL for schedule parsing (optional) - `PROXY_URL` - URL for schedule parsing (optional)
- `PARSING_FAILURE_NOTIFICATIONS_TELEGRAM_BOTAPI_TOKEN` - Telegram bot token (optional) - `PARSING_FAILURE_NOTIFICATIONS_TELEGRAM_BOTAPI_TOKEN` - Telegram bot token (optional)
- `PARSING_FAILURE_NOTIFICATIONS_TELEGRAM_CHAT_ID` - Telegram chat ID (optional) - `PARSING_FAILURE_NOTIFICATIONS_TELEGRAM_CHAT_ID` - Telegram chat ID (optional)

View File

@@ -133,16 +133,25 @@ rsync -av --exclude='node_modules' \
--exclude='.next' \ --exclude='.next' \
--exclude='.git' \ --exclude='.git' \
--exclude='*.log' \ --exclude='*.log' \
--exclude='.env*' \ --exclude='.env.local' \
--exclude='.env.development' \
--exclude='.env.development.local' \
--exclude='.env.test' \
--exclude='.env.test.local' \
--exclude='*.md' \ --exclude='*.md' \
"$PROJECT_DIR/" "$INSTALL_DIR/" "$PROJECT_DIR/" "$INSTALL_DIR/"
# Create .env.production if it doesn't exist # Handle .env file
if [ ! -f "$INSTALL_DIR/.env.production" ]; then if [ -f "$PROJECT_DIR/.env" ] && [ ! -f "$INSTALL_DIR/.env" ]; then
echo -e "${YELLOW}Creating .env.production from example...${NC}" echo -e "${YELLOW}Copying .env file...${NC}"
cp "$PROJECT_DIR/.env" "$INSTALL_DIR/.env"
elif [ -f "$INSTALL_DIR/.env" ]; then
echo -e "${GREEN}Using existing .env file in installation directory${NC}"
else
echo -e "${YELLOW}No .env file found. Creating from example...${NC}"
if [ -f "$INSTALL_DIR/.env.production.example" ]; then if [ -f "$INSTALL_DIR/.env.production.example" ]; then
cp "$INSTALL_DIR/.env.production.example" "$INSTALL_DIR/.env.production" cp "$INSTALL_DIR/.env.production.example" "$INSTALL_DIR/.env"
echo -e "${YELLOW}Please edit $INSTALL_DIR/.env.production with your configuration${NC}" echo -e "${YELLOW}Please edit $INSTALL_DIR/.env with your configuration${NC}"
fi fi
fi fi
@@ -191,7 +200,7 @@ systemctl enable "$SERVICE_NAME.service"
echo -e "\n${GREEN}=== Installation completed successfully! ===${NC}\n" echo -e "\n${GREEN}=== Installation completed successfully! ===${NC}\n"
echo -e "${YELLOW}Next steps:${NC}" echo -e "${YELLOW}Next steps:${NC}"
echo -e "1. Edit environment variables: ${GREEN}$INSTALL_DIR/.env.production${NC}" echo -e "1. Edit environment variables: ${GREEN}$INSTALL_DIR/.env${NC}"
echo -e "2. Update systemd service if needed: ${GREEN}/etc/systemd/system/$SERVICE_NAME.service${NC}" echo -e "2. Update systemd service if needed: ${GREEN}/etc/systemd/system/$SERVICE_NAME.service${NC}"
echo -e "3. Start the service: ${GREEN}systemctl start $SERVICE_NAME${NC}" echo -e "3. Start the service: ${GREEN}systemctl start $SERVICE_NAME${NC}"
echo -e "4. Check status: ${GREEN}systemctl status $SERVICE_NAME${NC}" echo -e "4. Check status: ${GREEN}systemctl status $SERVICE_NAME${NC}"

View File

@@ -17,7 +17,7 @@ Environment=HOSTNAME=0.0.0.0
# Environment=PARSING_FAILURE_NOTIFICATIONS_TELEGRAM_CHAT_ID=your_chat_id_here # Environment=PARSING_FAILURE_NOTIFICATIONS_TELEGRAM_CHAT_ID=your_chat_id_here
# Load environment variables from file (optional) # Load environment variables from file (optional)
# EnvironmentFile=/opt/kspguti-schedule/.env.production # EnvironmentFile=/opt/kspguti-schedule/.env
# Use standalone server from Next.js build # Use standalone server from Next.js build
ExecStart=/usr/bin/node /opt/kspguti-schedule/.next/standalone/server.js ExecStart=/usr/bin/node /opt/kspguti-schedule/.next/standalone/server.js