From 1740891f457921ebc8730b731f181a1abd5734d1 Mon Sep 17 00:00:00 2001 From: Amparo Oliver Date: Mon, 14 Aug 2023 10:17:13 -0400 Subject: [PATCH] Setting up as a Service Documentation --- setting-up-as-a-service.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 setting-up-as-a-service.md diff --git a/setting-up-as-a-service.md b/setting-up-as-a-service.md new file mode 100644 index 0000000..e3c0491 --- /dev/null +++ b/setting-up-as-a-service.md @@ -0,0 +1,51 @@ +# Levantar th-app-java como Servicio + +## Introducción +Esta guía documenta los pasos necesarios para levantar la aplicación Spring Boot "th-app-java" como un servicio utilizando systemd en un sistema Linux. + +### Paso 1: Clonar el Repositorio +Clona el repositorio "th-app-java" en tu sistema local. +##### Tener en cuenta: +El archivo JAR de la aplicación se encuentra en la ruta: /th-app-java/curriculumsearch/curriculumsearch-0.0.1-SNAPSHOT.jar + +#### Paso 2: Crear un Archivo de Servicio de systemd +1. Abre una terminal y crea el archivo de servicio utilizando el editor nano: +sudo nano /etc/systemd/system/th-app-java.service + +2. Agrega el siguiente contenido al archivo de servicio: +``` +[Unit] +Description=My Spring Boot Application +After=syslog.target + +[Service] +User=roshka +ExecStart=/usr/bin/java -jar /home/roshka/th-app-java/curriculumsearch/curriculumsearch-0.0.1-SNAPSHOT.jar +SuccessExitStatus=143 +Restart=always +RestartSec=30 +ExecStop=/bin/kill -TERM $MAINPID + +[Install] +WantedBy=multi-user.target +``` +Antes de levantar el servicio, asegúrate de que los siguientes valores en el archivo de servicio son correctos: +**User:** Debe coincidir con el usuario en tu sistema (en este caso, roshka). +**ExecStart:** Debe apuntar a la ubicación correcta del archivo JAR. + +### Paso 3: Gestión del Servicio +1. Recarga la configuración de systemd: +```sudo systemctl daemon-reload``` + +2. Inicia el servicio: +```sudo systemctl start th-app-java``` + +3. Habilita el inicio automático del servicio en el arranque: +```sudo systemctl enable th-app-java``` + +## Paso 6: Asegurar que este Activo +Comando: +```systemctl status``` +Salida: +```Active: active (running) indica que el servicio está activo y en ejecución.``` + -- libgit2 0.26.0