[Unit] Description=chatgpt-chatbot (OpenAI Responses API server) After=network-online.target Wants=network-online.target [Service] Type=simple User=chatbot Group=chatbot WorkingDirectory=/opt/chatgpt-chatbot # The key is read from here by systemd, never from source or the command line. # Keep it at 0600 root:chatbot — systemd reads it as root, before dropping # privileges, so the chatbot user never needs read access to the file. EnvironmentFile=/etc/chatgpt-chatbot.env ExecStart=/usr/bin/node src/server.js Restart=always RestartSec=3 # SIGTERM lets the server finish in-flight requests; it exits on its own. KillSignal=SIGTERM TimeoutStopSec=20 StandardOutput=journal StandardError=journal SyslogIdentifier=chatgpt-chatbot # Hardening: the process only needs to read its own code and talk to the # network. Everything else is denied, so a compromise through a dependency has # very little to reach for. NoNewPrivileges=true PrivateTmp=true PrivateDevices=true ProtectSystem=strict ProtectHome=true ProtectKernelTunables=true ProtectKernelModules=true ProtectControlGroups=true RestrictAddressFamilies=AF_INET AF_INET6 RestrictNamespaces=true LockPersonality=true MemoryDenyWriteExecute=false SystemCallArchitectures=native [Install] WantedBy=multi-user.target