@@ -126,7 +126,8 @@ func init() {
126126
127127 uiLogsDirPath := kos .GetDotKelpWorkingDir ().Join (uiLogsDir )
128128 log .Printf ("calling mkdir on uiLogsDirPath: %s ..." , uiLogsDirPath .AsString ())
129- e = kos .Mkdir (uiLogsDirPath )
129+ // no need to pass a userID since we are not running under the context of any user at this point
130+ e = kos .Mkdir ("_" , uiLogsDirPath )
130131 if e != nil {
131132 panic (errors .Wrap (e , "could not mkdir on uiLogsDirPath: " + uiLogsDirPath .AsString ()))
132133 }
@@ -293,29 +294,34 @@ func init() {
293294 ccxtBinPath := ccxtDestDir .Join (ccxtBinaryName )
294295
295296 log .Printf ("mkdir ccxtDirPath: %s ..." , ccxtDirPath .AsString ())
296- e := kos .Mkdir (ccxtDirPath )
297+ // no need to pass a userID since we are not running under the context of any user at this point
298+ e := kos .Mkdir ("_" , ccxtDirPath )
297299 if e != nil {
298300 panic (fmt .Errorf ("could not mkdir for ccxtDirPath: %s" , e ))
299301 }
300302
301303 if runtime .GOOS == "windows" {
302304 ccxtSourceDir := kos .GetBinDir ().Join ("ccxt" ).Join (ccxtFilenameNoExt )
303- e = copyCcxtFolder (kos , ccxtSourceDir , ccxtDestDir )
305+ // no need to pass a userID since we are not running under the context of any user at this point
306+ e = copyCcxtFolder (kos , "_" , ccxtSourceDir , ccxtDestDir )
304307 if e != nil {
305308 panic (e )
306309 }
307310 } else {
308311 ccxtBundledZipPath := kos .GetBinDir ().Join ("ccxt" ).Join (filenameWithExt )
309312 ccxtZipDestPath := ccxtDirPath .Join (filenameWithExt )
310- e = copyOrDownloadCcxtBinary (kos , ccxtBundledZipPath , ccxtZipDestPath , filenameWithExt )
313+ // no need to pass a userID since we are not running under the context of any user at this point
314+ e = copyOrDownloadCcxtBinary (kos , "_" , ccxtBundledZipPath , ccxtZipDestPath , filenameWithExt )
311315 if e != nil {
312316 panic (e )
313317 }
314318
315- unzipCcxtFile (kos , ccxtDirPath , ccxtBinPath , filenameWithExt )
319+ // no need to pass a userID since we are not running under the context of any user at this point
320+ unzipCcxtFile (kos , "_" , ccxtDirPath , ccxtBinPath , filenameWithExt )
316321 }
317322
318- e = runCcxtBinary (kos , ccxtBinPath )
323+ // no need to pass a userID since we are not running under the context of any user at this point
324+ e = runCcxtBinary (kos , "_" , ccxtBinPath )
319325 if e != nil {
320326 panic (e )
321327 }
@@ -476,13 +482,14 @@ func setMiddleware(r *chi.Mux) {
476482
477483func copyCcxtFolder (
478484 kos * kelpos.KelpOS ,
485+ userID string ,
479486 ccxtSourceDir * kelpos.OSPath ,
480487 ccxtDestDir * kelpos.OSPath ,
481488) error {
482489 log .Printf ("copying ccxt directory from %s to location %s ..." , ccxtSourceDir .AsString (), ccxtDestDir .AsString ())
483490
484491 cpCmd := fmt .Sprintf ("cp -a %s %s" , ccxtSourceDir .Unix (), ccxtDestDir .Unix ())
485- _ , e := kos .Blocking ("cp-ccxt" , cpCmd )
492+ _ , e := kos .Blocking (userID , "cp-ccxt" , cpCmd )
486493 if e != nil {
487494 return fmt .Errorf ("unable to copy ccxt directory from %s to %s: %s" , ccxtSourceDir .AsString (), ccxtDestDir .AsString (), e )
488495 }
@@ -493,6 +500,7 @@ func copyCcxtFolder(
493500
494501func copyOrDownloadCcxtBinary (
495502 kos * kelpos.KelpOS ,
503+ userID string ,
496504 ccxtBundledZipPath * kelpos.OSPath ,
497505 ccxtZipDestPath * kelpos.OSPath ,
498506 filenameWithExt string ,
@@ -505,7 +513,7 @@ func copyOrDownloadCcxtBinary(
505513 log .Printf ("copying ccxt from %s to location %s ..." , ccxtBundledZipPath .Unix (), ccxtZipDestPath .Unix ())
506514
507515 cpCmd := fmt .Sprintf ("cp %s %s" , ccxtBundledZipPath .Unix (), ccxtZipDestPath .Unix ())
508- _ , e = kos .Blocking ("cp-ccxt" , cpCmd )
516+ _ , e = kos .Blocking (userID , "cp-ccxt" , cpCmd )
509517 if e != nil {
510518 return fmt .Errorf ("unable to copy ccxt zip file from %s to %s: %s" , ccxtBundledZipPath .Unix (), ccxtZipDestPath .Unix (), e )
511519 }
@@ -546,6 +554,7 @@ func copyOrDownloadCcxtBinary(
546554
547555func unzipCcxtFile (
548556 kos * kelpos.KelpOS ,
557+ userID string ,
549558 ccxtDir * kelpos.OSPath ,
550559 ccxtBinPath * kelpos.OSPath ,
551560 filenameWithExt string ,
@@ -558,21 +567,21 @@ func unzipCcxtFile(
558567
559568 log .Printf ("unzipping file %s ... " , filenameWithExt )
560569 zipCmd := fmt .Sprintf ("cd %s && unzip %s" , ccxtDir .Unix (), filenameWithExt )
561- _ , e := kos .Blocking ("zip" , zipCmd )
570+ _ , e := kos .Blocking (userID , "zip" , zipCmd )
562571 if e != nil {
563572 log .Fatal (errors .Wrap (e , fmt .Sprintf ("unable to unzip file %s in directory %s" , filenameWithExt , ccxtDir .AsString ())))
564573 }
565574 log .Printf ("done\n " )
566575}
567576
568- func runCcxtBinary (kos * kelpos.KelpOS , ccxtBinPath * kelpos.OSPath ) error {
577+ func runCcxtBinary (kos * kelpos.KelpOS , userID string , ccxtBinPath * kelpos.OSPath ) error {
569578 if _ , e := os .Stat (ccxtBinPath .Native ()); os .IsNotExist (e ) {
570579 return fmt .Errorf ("path to ccxt binary (%s) does not exist" , ccxtBinPath .AsString ())
571580 }
572581
573582 log .Printf ("running binary %s" , ccxtBinPath .AsString ())
574583 // TODO CCXT should be run at the port specified by rootCcxtRestURL, currently it will default to port 3000 even if the config file specifies otherwise
575- _ , e := kos .Background ("ccxt-rest" , ccxtBinPath .Unix ())
584+ _ , e := kos .Background (userID , "ccxt-rest" , ccxtBinPath .Unix ())
576585 if e != nil {
577586 log .Fatal (errors .Wrap (e , fmt .Sprintf ("unable to run ccxt file at location %s" , ccxtBinPath .AsString ())))
578587 }
@@ -653,7 +662,8 @@ func writeTrayIcon(kos *kelpos.KelpOS, trayIconPath *kelpos.OSPath, assetsDirPat
653662 // create dir if not exists
654663 if _ , e := os .Stat (assetsDirPath .Native ()); os .IsNotExist (e ) {
655664 log .Printf ("mkdir assetsDirPath: %s ..." , assetsDirPath .AsString ())
656- e = kos .Mkdir (assetsDirPath )
665+ // no need to pass a userID since we are not running under the context of any user at this point
666+ e = kos .Mkdir ("_" , assetsDirPath )
657667 if e != nil {
658668 return errors .Wrap (e , "could not mkdir for assetsDirPath: " + assetsDirPath .AsString ())
659669 }
0 commit comments