본문 바로가기
백엔드/Java

Spring @Scheduled 사용시

by david100gom 2024. 3. 20.

Tomcat의 Host의 appBase 와 Context 의 docBase 문제로 인해 TaskScheduler 가 중복으로 구동될 수 있다.

[스케줄러 동일것이 2번 호출됨]
<Service name="Catalina2">
 
   <Connector port="8601" redirectPort="8445" connectionTimeout="20000" enableLookups="false" maxThreads="1024"
               minSpareThreads="10" acceptCount="100" protocol="HTTP/1.1" URIEncoding="UTF-8" maxPostSize="-1" maxParameterCount="-1"/>
 
    <Engine name="Catalina" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.LockOutRealm">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
      </Realm>
      <Host name="localhost"  appBase="/data/www/" unpackWARs="true" autoDeploy="true">
        <Valve className="org.apache.catalina.valves.RemoteIpValve" protocolHeader="x-forwarded-proto" />
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="/data/logs/pntbiz_admin_log/localhost-log"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t "%r" %s %b" />
        <Context reloadable="true" docBase="admin" path="">
         </Context>
        <Alias>dev-admin.indoorplus.io</Alias>
      </Host>
    </Engine>
  </Service>
</Server>
 
[스케줄러 정상 호출됨]
<Service name="Catalina2">
 
   <Connector port="8601" redirectPort="8445" connectionTimeout="20000" enableLookups="false" maxThreads="1024"
               minSpareThreads="10" acceptCount="100" protocol="HTTP/1.1" URIEncoding="UTF-8" maxPostSize="-1" maxParameterCount="-1"/>
 
    <Engine name="Catalina" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.LockOutRealm">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
      </Realm>
      <Host name="localhost" appBase="" unpackWARs="true" autoDeploy="true">
        <Valve className="org.apache.catalina.valves.RemoteIpValve" protocolHeader="x-forwarded-proto" />
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="/data/logs/pntbiz_admin_log/localhost-log"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t "%r" %s %b" />
        <Context reloadable="true" docBase="/data/www/admin" path="">
         </Context>
        <Alias>dev-admin.indoorplus.io</Alias>
      </Host>
    </Engine>
  </Service>
</Server>

 

댓글