-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.ps1
More file actions
39 lines (29 loc) · 1.34 KB
/
run.ps1
File metadata and controls
39 lines (29 loc) · 1.34 KB
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
using module ".\app\module\logger.psm1"
function run {
# 例外が発生したら、catchに入ってほしい
$ErrorActionPreference = "Stop"
# プロジェクトのルートディレクトリ
Set-Variable -name ROOT_DIR -value @(Split-Path $script:myInvocation.MyCommand.Path -Parent).Trim() -option constant
# ログ関連
Set-Variable -name LOG_FILE_NAME -value "send-cdi-smart.log" -option constant
Set-Variable -name LOG_DIR -value ($ROOT_DIR + "\log") -option constant
Set-Variable -name LOG_FILE_PATH -value ($LOG_DIR + "\" + $LOG_FILE_NAME) -option constant
# logディレクトリがなかったら作成
if(!(Test-Path $LOG_DIR)){
New-Item $LOG_DIR -ItemType Directory
}
# ログ出力開始
[object] $logger = [Logger]::new($LOG_FILE_PATH)
# アプリケーション設定ファイル
Set-Variable -name CONFIG_FILE_NAME -value "config.json" -option constant
Set-Variable -name CONFIG_FILE_PATH -value ($ROOT_DIR + "\" + $CONFIG_FILE_NAME) -option constant
# 設定ファイルがあれば実行
if(Test-Path $CONFIG_FILE_PATH){
. ".\app\main"
main
}else{
$logger.Logging("error", "[{0}] is NOT exists." -f $CONFIG_FILE_PATH)
}
$logger.Logging("info", "=== Quit the Application. ===")
}
run