File tree 4 files changed +62
-3
lines changed
src/main/java/com/animecap/system
4 files changed +62
-3
lines changed Original file line number Diff line number Diff line change @@ -20,9 +20,15 @@ buildscript {
20
20
}
21
21
dependencies {
22
22
classpath(" org.springframework.boot:spring-boot-gradle-plugin:1.4.2.RELEASE" )
23
+ classpath ' org.ajoberstar:grgit:1.1.0'
23
24
}
24
25
}
25
-
26
+ import groovy.json.JsonSlurper
27
+ ext {
28
+ git = org.ajoberstar.grgit.Grgit . open(file(' ./' ))
29
+ revision = git. head(). abbreviatedId
30
+ buildnum = " $System . env . BUILD_NUMBER "
31
+ }
26
32
jar {
27
33
baseName = ' animecap'
28
34
version = ' 0.0.1'
Original file line number Diff line number Diff line change
1
+ package com .animecap .system ;
2
+
3
+ import org .springframework .context .annotation .Bean ;
4
+ import org .springframework .stereotype .Component ;
5
+
6
+ import java .io .File ;
7
+ import java .util .logging .Logger ;
8
+
9
+ /**
10
+ * Created by Nathaniel on 3/2/2017.
11
+ */
12
+ @ Component
13
+ public class CloseHandler implements Runnable {
14
+ @ Bean
15
+ public boolean createThread (){
16
+ new Thread (new CloseHandler ()).start ();
17
+ return true ;
18
+ }
19
+
20
+ protected Logger logger = Logger .getLogger (CloseHandler .class .getName ());
21
+
22
+ public void run () {
23
+ try {
24
+ File file = new File (CloseHandler .class .getProtectionDomain ().getCodeSource ().getLocation ().toString ().split ("!" )[0 ].split ("jar:file:" )[1 ]);
25
+ while (true ) {
26
+ if (!file .exists ()){
27
+ logger .info ("Jar was deleted, closing down server!" );
28
+ logger .info ("Closing in 30 seconds!" );
29
+ System .exit (0 );
30
+ }
31
+ try {
32
+ Thread .sleep (200 );
33
+ } catch (Exception e ) {
34
+ e .printStackTrace ();
35
+ }
36
+ }
37
+ }catch (Exception e ){
38
+ e .printStackTrace ();
39
+ }
40
+ }
41
+ }
Original file line number Diff line number Diff line change 1
1
package com .animecap .system ;
2
2
import org .springframework .boot .SpringApplication ;
3
3
import org .springframework .boot .autoconfigure .SpringBootApplication ;
4
+ import org .springframework .boot .builder .SpringApplicationBuilder ;
4
5
import org .springframework .scheduling .annotation .EnableScheduling ;
5
6
6
7
import javax .annotation .PostConstruct ;
7
8
import java .io .File ;
9
+ import java .util .HashMap ;
8
10
9
11
/**
10
12
* Created by Nathaniel on 11/26/2016.
@@ -16,10 +18,19 @@ public class VideoConverter {
16
18
public static String sourceDirectory = "sources/" ;
17
19
public static String uploadDirectory = "uploads/" ;
18
20
public static void main (String [] args ) {
19
- SpringApplication app = new SpringApplication (VideoConverter .class );
21
+ System .setProperty ("spring.config.name" , "www-server" );
22
+
20
23
if (!new File ("uploads/" ).exists ()){
21
24
new File ("uploads/" ).mkdir ();
22
25
}
23
- app .run (args );
26
+
27
+ int port =2115 ;
28
+
29
+ System .setProperty ("server.port" , String .valueOf (port ));
30
+
31
+ HashMap <String , Object > props = new HashMap <>();
32
+ props .put ("server.port" , port );
33
+
34
+ new SpringApplicationBuilder ().sources (VideoConverter .class ).properties (props ).run (args );
24
35
}
25
36
}
Original file line number Diff line number Diff line change @@ -65,4 +65,5 @@ public Video video(@RequestParam("uuid") String vUUID) {
65
65
}
66
66
67
67
68
+
68
69
}
You can’t perform that action at this time.
0 commit comments