-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApplication.cfc
81 lines (69 loc) · 2.66 KB
/
Application.cfc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/**
*******************************************************************************
* Coldthumbs
* Copyright 2018 - Simian Enterprises Ltd.
* www.simianenterprises.co.uk
*******************************************************************************
* @author Gary Stanton
*/
component{
this.name = hash( getCurrentTemplatePath() );
this.mappings[ '/docbox' ] = getDirectoryFromPath( getCurrentTemplatePath() ) & 'docbox/';
this.mappings[ '/models' ] = getDirectoryFromPath( getCurrentTemplatePath() ) & 'models/';
public boolean function onApplicationStart(){
// Instantiate ColdThumbs
Application.com.coldThumbs = new models.coldThumbs()
.setMaxThreads(2)
.setImageMagickLocation("C:\Program Files\ImageMagick-7.0.8-Q16\magick.exe");
// CFConcurrent for threading
if (fileExists(getDirectoryFromPath(getCurrentTemplatePath()) & 'cfconcurrent/ExecutorService.cfc')) {
Application.executorService = createObject("component", "cfconcurrent.ExecutorService")
.init( serviceName = "executorServiceExample", maxConcurrent = 2, maxWorkQueueSize = 100000);
Application.executorService.setLoggingEnabled( true );
Application.executorService.start();
Application.com.coldThumbs.setExecutorService(Application.executorService)
}
return true;
}
public boolean function onRequestStart( string targetPage ){
if (structKeyExists(URL, 'reinit')) {
applicationStop();
onApplicationStop();
location(url = '/', addtoken = false);
}
if (structKeyExists(URL, 'IM')) {
lock timeout="5" scope="Application" type="exclusive" {
Application.com.ColdThumbs.setImageMagickLocation(URL.IM ? "C:\Program Files\ImageMagick-7.0.8-Q16\magick.exe" : '');
}
}
if (structKeyExists(URL, 'Con')) {
lock timeout="5" scope="Application" type="exclusive" {
if (URL.con) {
Application.com.coldThumbs = new models.coldThumbs()
.setMaxThreads(Application.com.coldThumbs.getMaxThreads())
.setExecutorService(Application.executorService)
.setImageMagickLocation(Application.com.coldThumbs.getImageMagickLocation());
}
else {
Application.com.coldThumbs = new models.coldThumbs()
.setMaxThreads(Application.com.coldThumbs.getMaxThreads())
.setImageMagickLocation(Application.com.coldThumbs.getImageMagickLocation());
}
}
}
if (structKeyExists(URL, 'Threads') AND isNumeric(URL.Threads)) {
lock timeout="5" scope="Application" type="exclusive" {
Application.com.ColdThumbs.setMaxThreads(URL.Threads);
}
}
return true;
}
function onApplicationStop(){
if (StructKeyExists(Application, 'executorService')) {
Application.executorService.stop();
}
}
function onError(e) {
writeDump(e);
}
}