[컴] systemctl --user도 linger 설정이 필요하다.

스프링 이유없이 죽는 이유

systemctl --user도 linger 설정이 필요하다.

systemctl --user 를 사용하는 경우에도 linger 설정이 필요하다.

만약 ssh login 을 해서 서버를 띄운 후에 ssh세션을 모두 닫는다면 그 시점에 서버가 종료될 것이다.

sudo loginctl enable-linger <user_id>

현재 linger설정 상태를 확인하려면 아래와 같은 command를 치면 된다.

loginctl user-status <user_id>

$ loginctl user-status admin
admin (1000)
           Since: Thu 2024-03-28 06:16:00 UTC; 4h 42min ago
           State: active
        Sessions: 642 *639
          Linger: no
            Unit: user-1000.slice
                  ├─session-639.scope
                  │ ├─67433 sshd: admin [priv]
                  │ ├─67456 sshd: admin@pts/0
                  │ ├─67457 -bash
                  │ ├─67906 loginctl user-status admin
                  │ └─67907 pager
                  ├─session-642.scope
                  │ ├─67469 sshd: admin [priv]
                  │ ├─67476 sshd: admin@notty
                  │ └─67477 /usr/lib/openssh/sftp-server
                  └─user@1000.service
                    ├─app.slice
                    │ └─myserver.service
                    │   └─67481 /usr/bin/java -Dspring.profiles.active=prod -Xms512M -Xmx1G -XX:+UseZGC -jar /services/myserver/myserver-0.0.1-SNAPSHOT.jar
                    └─init.scope
                      ├─67436 /lib/systemd/systemd --user
                      └─67437 (sd-pam)

개인적인 경험

처음에 systemctl --user 를 사용할 떄는 이것이 systemctl 과 같다고 봐서, daemon 으로 동작하기에 따로 nohup 등의 설정이 필요없다고 생각했다. 그래서 systemctl --user를 이용해서 웹서버를 실행했었다.

하지만 이 서버가 종종 gracefully shutdown 으로 죽었다.(spring server 였다.) 당연히 웹서버(WAS) 로그에는 남아있는 것이 없었다.

원인을 찾다가 deamon.log를 보게 되었다. 여기서 systemd가 stop 된 것을 보고 웹서버(WAS)가 죽은 이유를 추측해 볼 수 있었다. 그래서 결국 linger 설정이 필요한 것을 알았다.

cat /var/log/daemon.log | grep "Mar 28 06:12"

...
Mar 28 06:12:45 i-0127a77bf7ac67eaf systemd[1]: Stopping User Manager for UID 1000...
Mar 28 06:12:45 i-0127a77bf7ac67eaf systemd[104663]: Stopped target Main User Target.
Mar 28 06:12:45 i-0127a77bf7ac67eaf systemd[104663]: Stopping PMS api server(fish)...

Reference

  1. https://github.com/systemd/systemd/issues/8486#issuecomment-374318982

[컴] jenkins 의 plugin list 를 추출하는 법

jenkins plugin 설치 / batch / cli 에서 설치 / 뽑기

jenkins 의 plugin list 를 추출하는 법

jenkins web page 에서 추출하기

https:///script 로 가서

Jenkins.instance.pluginManager.plugins.each{
  plugin -> 
    println ("${plugin.getShortName()}:${plugin.getVersion()}")
}

jenkins cli 로 뽑기

cli 는 다음처럼 받을 수 있다.

curl https:///jnlpJars/jenkins-cli.jar -o jenkins-cli.jar
// get_plugin_list.groovy
def plugins = jenkins.model.Jenkins.instance.getPluginManager().getPlugins()
plugins.each {println "${it.getShortName()}: ${it.getVersion()}"}
java -jar jenkins-cli.jar -s https:// -auth "namh:who1sthegoodman" groovy = < get_plugin_list.groovy >  plugins.txt

jenkins cli 로 plugin 설치

testing - How to install jenkins plugins from command line? - Stack Overflow

java -jar jenkins-cli.jar -s https://inhouse.foodpang.co/ci -auth <username>:<password> install-plugin <plugin_name1> <plugin_name2> ...

Reference

  1. How to get a list of installed Jenkins plugins with name and version pair - Stack Overflow

[컴][유틸] 2024-03, 에디터

hexa editor / hex editor / 괜찮은 hex editor

2024-03, 에디터

See Also

  1. 쿠…sal: [컴] sublime text 2 에서 binary 파일을 text 파일로 열기
  2. 쿠…sal: [컴][유틸] 대용량 파일 뷰어 big size file viewer

[컴] gradle java build 에서 git commit hash id 를 추가

스프링 / 스프링부트 / spring /

gradle java build 에서 git commit hash id 를 추가

com.gorylenko.gradle-git-properties gradle plugin 을 이용할 것이다.

build.gralde

아래처럼 build.gradle 을 설정하자. build 를 하면 build/resources/main/git.properties 가 만들어진다.

plugins {
  id "com.gorylenko.gradle-git-properties" version "2.4.1"
}
...
gitProperties {
    keys = ['git.branch','git.commit.id','git.commit.time']
    customProperty 'greeting', 'Hello' // expression
    // Customize file name (could be a file name or a relative file path below gitPropertiesResourceDir dir)
    gitPropertiesName = "my-git-file.properties"
    dotGitDirectory = file("${project.rootDir}/.git") # 정의하지 않으면, 자동으로 .git folder를 찾는다.
}

git.properties

위에서 gitPropertiesName 로 properties file 의 이름을 변경했기에, build/resources/main/my-git-file.properties 가 만들어진다.

my-git-file.properties 의 내용은 다음과 같다.

// build/resources/main/my-git-file.properties
git.branch=mybranch_name
git.commit.id=0c5da9f4f7312bb6c02f21c47ae129b31a006046
git.commit.time=2024-03-10T11\:18\:37+0900
greeting=Hello

jar 에서 위치

그리고 이것은 gradlew build 를 할 때 아래 경로에 들어가게 된다.

  • myjar-0.0.1.jar\BOOT-INF\classes\git.properties

SpringBoot

[컴] amazone 의 Correctto 17

 

amazone 의 Correctto 17

아마존에서 제공하는 OpenJDK 17 로 보면 된다. LTS(Long Term Support) 를 지원한다.

curl -LO https://corretto.aws/downloads/latest/amazon-corretto-17-x64-linux-jdk.tar.gz

아래 링크에 가면, deb, rpm 등도 다운로드 받을 수 있다.

[컴] MySql virtual column

mariadb 마리아db /

MySql virtual column

ALTER TABLE t1 ADD COLUMN c2 INT GENERATED ALWAYS AS (c1 + 1) STORED;
ALTER TABLE t1 ADD COLUMN c2 INT GENERATED ALWAYS AS (c1 + 1) VIRTUAL;

다른 table의 column을 이용하려면, view를 만드는 것도 방법이다.

Reference

  1. Generated (Virtual and Persistent/Stored) Columns - MariaDB Knowledge Base
  2. mysql - Stored/Virtual Generated Column- Pros/Cons/Best Practices? - Stack Overflow

[컴] SpringBoot 3.x 의 logging 설정

logback config / springboot log configuration / log config / spring log / 기간 설정

SpringBoot 3.x 의 logging 설정

spring-boot-starter-web을 사용한다면 logback 이 dependency 에 걸려있어서 자동으로 추가된다.

좀 더 자세한 logback option 의 설명

logback.rollingpolicy.max-history 에 대한 설명

TimeBasedRollingPolicy 를 사용한다면, max-history 는 ’며칠의 log를 보관하는 지를 결정’하는 설정이 된다고 한다.

totalSizeCap 을 설정해놓는 것이 disk usage 를 관리하는데 도움이 될 것이라고 한다.