Fix issue the cannot find the working directroy
Some checks are pending
CodeQL / Analyze (csharp) (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run

This commit is contained in:
Namhyeon Go 2024-07-29 16:06:04 +09:00
parent 95a7588726
commit d5f55e0f28
7 changed files with 18 additions and 44 deletions

View File

@ -14,15 +14,15 @@ namespace WelsonJS.Service
{ {
if (Environment.UserInteractive) if (Environment.UserInteractive)
{ {
ServiceMain svc = new ServiceMain(); ServiceMain svc = new ServiceMain(args);
svc.TestStartupAndStop(args); svc.TestStartupAndStop();
} }
else else
{ {
ServiceBase[] ServicesToRun; ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[] ServicesToRun = new ServiceBase[]
{ {
new ServiceMain() new ServiceMain(args)
}; };
ServiceBase.Run(ServicesToRun); ServiceBase.Run(ServicesToRun);
} }

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를 // 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를
// 기본값으로 할 수 있습니다. // 기본값으로 할 수 있습니다.
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.2.7.25")] [assembly: AssemblyVersion("0.2.7.26")]
[assembly: AssemblyFileVersion("0.2.7.25")] [assembly: AssemblyFileVersion("0.2.7.26")]

View File

@ -20,6 +20,8 @@
* *
* references: * references:
* - https://learn.microsoft.com/en-us/dotnet/framework/windows-services/how-to-debug-windows-service-applications * - https://learn.microsoft.com/en-us/dotnet/framework/windows-services/how-to-debug-windows-service-applications
* - https://stackoverflow.com/questions/6490979/how-to-pass-parameters-to-windows-service
* - https://stackoverflow.com/questions/42812333/pass-an-argument-to-a-windows-service-at-automatic-startup
*/ */
using System; using System;
using System.ServiceProcess; using System.ServiceProcess;
@ -39,28 +41,35 @@ namespace WelsonJS.Service
private string scriptName; private string scriptName;
private ScriptControl scriptControl; private ScriptControl scriptControl;
private string logFilePath; private string logFilePath;
private string[] _args;
private readonly string appName = "WelsonJS"; private readonly string appName = "WelsonJS";
public ServiceMain() public ServiceMain(string[] args)
{ {
InitializeComponent(); InitializeComponent();
// set the log file path // set the log file path
logFilePath = Path.Combine(Path.GetTempPath(), "WelsonJS.Service.Log.txt"); logFilePath = Path.Combine(Path.GetTempPath(), "WelsonJS.Service.Log.txt");
Log(appName + " Service Loaded"); Log(appName + " Service Loaded");
// set service arguments
// An auto-start service application should receive arguments at the class.
_args = args;
} }
internal void TestStartupAndStop(string[] args) internal void TestStartupAndStop()
{ {
this.OnStart(args); this.OnStart(_args);
Console.ReadLine(); Console.ReadLine();
this.OnStop(); this.OnStop();
} }
protected override void OnStart(string[] args) protected override void OnStart(string[] args)
{ {
base.OnStart(args);
// mapping arguments to each variables // mapping arguments to each variables
var arguments = ParseArguments(args); var arguments = ParseArguments(_args);
foreach (KeyValuePair<string, string> entry in arguments) foreach (KeyValuePair<string, string> entry in arguments)
{ {
switch (entry.Key) switch (entry.Key)

View File

@ -1,34 +0,0 @@
어셈블리 'C:\Users\knh94\OneDrive\문서\GitHub\welsonjs\bin\x86\WelsonJS.Service.exe'을(를) 설치하고 있습니다.
영향을 받는 매개 변수:
logtoconsole =
logfile = C:\Users\knh94\OneDrive\문서\GitHub\welsonjs\bin\x86\WelsonJS.Service.InstallLog
assemblypath = C:\Users\knh94\OneDrive\문서\GitHub\welsonjs\bin\x86\WelsonJS.Service.exe
WelsonJS.Service 서비스를 설치하고 있습니다...
EventLog 소스 WelsonJS.Service을(를) 로그 Application에 만들고 있습니다...
어셈블리 'C:\Users\knh94\OneDrive\문서\GitHub\welsonjs\bin\x86\WelsonJS.Service.exe'을(를) 롤백하고 있습니다.
영향을 받는 매개 변수:
logtoconsole =
logfile = C:\Users\knh94\OneDrive\문서\GitHub\welsonjs\bin\x86\WelsonJS.Service.InstallLog
assemblypath = C:\Users\knh94\OneDrive\문서\GitHub\welsonjs\bin\x86\WelsonJS.Service.exe
이벤트 로그를 소스 WelsonJS.Service의 이전 상태로 복원하고 있습니다.
어셈블리 'C:\Users\knh94\OneDrive\문서\GitHub\welsonjs\bin\x86\WelsonJS.Service.exe'을(를) 제거하고 있습니다.
영향을 받는 매개 변수:
logtoconsole =
logfile = C:\Users\knh94\OneDrive\문서\GitHub\welsonjs\bin\x86\WelsonJS.Service.InstallLog
assemblypath = C:\Users\knh94\OneDrive\문서\GitHub\welsonjs\bin\x86\WelsonJS.Service.exe
EventLog 소스 WelsonJS.Service을(를) 제거하고 있습니다.
시스템에서 WelsonJS.Service 서비스를 제거하고 있습니다...
WelsonJS.Service 서비스가 시스템에서 제거되었습니다.
어셈블리 'C:\Users\knh94\OneDrive\문서\GitHub\welsonjs\bin\x86\WelsonJS.Service.exe'을(를) 설치하고 있습니다.
영향을 받는 매개 변수:
logtoconsole =
logfile = C:\Users\knh94\OneDrive\문서\GitHub\welsonjs\bin\x86\WelsonJS.Service.InstallLog
assemblypath = C:\Users\knh94\OneDrive\문서\GitHub\welsonjs\bin\x86\WelsonJS.Service.exe
WelsonJS.Service 서비스를 설치하고 있습니다...
WelsonJS.Service 서비스가 설치되었습니다.
EventLog 소스 WelsonJS.Service을(를) 로그 Application에 만들고 있습니다...
어셈블리 'C:\Users\knh94\OneDrive\문서\GitHub\welsonjs\bin\x86\WelsonJS.Service.exe'을(를) 커밋하고 있습니다.
영향을 받는 매개 변수:
logtoconsole =
logfile = C:\Users\knh94\OneDrive\문서\GitHub\welsonjs\bin\x86\WelsonJS.Service.InstallLog
assemblypath = C:\Users\knh94\OneDrive\문서\GitHub\welsonjs\bin\x86\WelsonJS.Service.exe

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.