0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

App Service Linux の WebJobs はどこで実行されているのかのメモ

Last updated at Posted at 2024-11-29

はじめに

image.png

サイドカーについて色々調べていて、そういえば同時期?に利用できるようになった WebJobs はどうなん?と思ってやってみた。

参考


そしたらこのエラー

[11/29/2024 08:35:05 > 56ce77: ERR ] An error occurred trying to start process 'node.exe' with working directory '/home/site/wwwroot/App_Data/jobs/continuous/myjob'. No such file or directory

image.png

エラーそのものはなんかすごくしょうもない。。。

が注目すべきはそのスタックトレース

[11/29/2024 08:35:05 > 56ce77: SYS INFO] Status changed to Running
[11/29/2024 08:35:05 > 56ce77: ERR ] An error occurred trying to start process 'node.exe' with working directory '/home/site/wwwroot/App_Data/jobs/continuous/myjob'. No such file or directory
[11/29/2024 08:35:05 > 56ce77: SYS ERR ] System.AggregateException: One or more errors occurred. (An error occurred trying to start process 'node.exe' with working directory '/home/site/wwwroot/App_Data/jobs/continuous/myjob'. No such file or directory)
 ---> System.ComponentModel.Win32Exception (2): An error occurred trying to start process 'node.exe' with working directory '/home/site/wwwroot/App_Data/jobs/continuous/myjob'. No such file or directory
   at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
   at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at Kudu.Core.Infrastructure.ProcessWrapper.Start() in C:\wagit\AAPT-Antares-Kudu\Kudu.Core\Infrastructure\ProcessWrapper.cs:line 27
   at Kudu.Core.Infrastructure.ProcessExtensions.Start(IProcess process, ITracer tracer, Stream output, Stream error, Stream input, IdleManager idleManager) in C:\wagit\AAPT-Antares-Kudu\Kudu.Core\Infrastructure\ProcessExtensions.cs:line 242
   at Kudu.Core.Infrastructure.Executable.ExecuteAsync(ITracer tracer, String arguments, Stream output, Stream error, Stream input, IdleManager idleManager) in C:\wagit\AAPT-Antares-Kudu\Kudu.Core\Infrastructure\Executable.cs:line 255
   --- End of inner exception stack trace ---
   at Kudu.Core.Infrastructure.Executable.ExecuteInternal(ITracer tracer, Func`2 onWriteOutput, Func`2 onWriteError, Encoding encoding, String arguments, Object[] args)
   at Kudu.Core.Infrastructure.Executable.ExecuteReturnExitCode(ITracer tracer, Action`1 onWriteOutput, Action`1 onWriteError, String arguments, Object[] args) in C:\wagit\AAPT-Antares-Kudu\Kudu.Core\Infrastructure\Executable.cs:line 165
   at Kudu.Core.Jobs.BaseJobRunner.RunJobInstance(JobBase job, IJobLogger logger, String runId, String trigger, ITracer tracer, Int32 port) in C:\wagit\AAPT-Antares-Kudu\Kudu.Core\Jobs\BaseJobRunner.cs:line 274
[11/29/2024 08:35:05 > 56ce77: SYS INFO] Process went down, waiting for 60 seconds

WebJobsは Kudu でやってるっぽい。サイドカーではないのかな。
Antares って、でてますけど。。。

でいろいろ気になってみてみたメモ。
とりあえず、StackOverflowのとおりshellを挟んでnodeを実行するようにしてみた。

echo "Hello webjob"
echo "run which node"
echo `which node`
echo "run node -v"
echo `node -v`

でその結果が

[11/29/2024 12:27:21 > 56ce77: SYS INFO] Status changed to Starting
[11/29/2024 12:27:22 > 56ce77: SYS INFO] WebJob singleton setting is True
[11/29/2024 12:27:22 > 56ce77: SYS INFO] WebJob singleton lock is acquired
[11/29/2024 12:27:22 > 56ce77: SYS INFO] Run script 'hello.sh' with script host - 'BashScriptHost'
[11/29/2024 12:27:22 > 56ce77: SYS INFO] Status changed to Running
[11/29/2024 12:27:22 > 56ce77: INFO] Hello webjob
[11/29/2024 12:27:22 > 56ce77: INFO] run which node
[11/29/2024 12:27:22 > 56ce77: INFO] /usr/local/bin/node
[11/29/2024 12:27:22 > 56ce77: INFO] run node -v
[11/29/2024 12:27:22 > 56ce77: INFO] v20.15.1
[11/29/2024 12:27:22 > 56ce77: SYS INFO] Status changed to Success
[11/29/2024 12:27:22 > 56ce77: SYS INFO] Process went down, waiting for 60 seconds

一方 Kudu Bash では
image.png

/usr/local/bin/node のバージョンが違う。

もう少し詳しく見てみる。

info.sh
#!/bin/sh
# this script log system info
cat /proc/self/cgroup
echo "whoami: $(whoami)"
echo "IP: $(ifconfig | grep inet | head -n 1 | awk '{print $2}')"

結果

[11/29/2024 12:48:24 > 56ce77: SYS INFO] Detected WebJob file/s were updated, refreshing WebJob
[11/29/2024 12:48:24 > 56ce77: SYS INFO] Status changed to Starting
[11/29/2024 12:48:24 > 56ce77: SYS INFO] WebJob singleton setting is True
[11/29/2024 12:48:24 > 56ce77: SYS INFO] WebJob singleton lock is acquired
[11/29/2024 12:48:24 > 56ce77: SYS INFO] Run script 'info.sh' with script host - 'BashScriptHost'
[11/29/2024 12:48:24 > 56ce77: SYS INFO] Status changed to Running
[11/29/2024 12:48:25 > 56ce77: INFO] 12:cpuset:/
[11/29/2024 12:48:25 > 56ce77: INFO] 11:blkio:/system.slice/lwasv2.service
[11/29/2024 12:48:25 > 56ce77: INFO] 10:devices:/system.slice/lwasv2.service
[11/29/2024 12:48:25 > 56ce77: INFO] 9:cpu,cpuacct:/system.slice/lwasv2.service
[11/29/2024 12:48:25 > 56ce77: INFO] 8:memory:/system.slice/lwasv2.service
[11/29/2024 12:48:25 > 56ce77: INFO] 7:freezer:/
[11/29/2024 12:48:25 > 56ce77: INFO] 6:perf_event:/
[11/29/2024 12:48:25 > 56ce77: INFO] 5:net_cls,net_prio:/
[11/29/2024 12:48:25 > 56ce77: INFO] 4:hugetlb:/
[11/29/2024 12:48:25 > 56ce77: INFO] 3:pids:/system.slice/lwasv2.service
[11/29/2024 12:48:25 > 56ce77: INFO] 2:rdma:/
[11/29/2024 12:48:25 > 56ce77: INFO] 1:name=systemd:/system.slice/lwasv2.service
[11/29/2024 12:48:25 > 56ce77: INFO] whoami: root
[11/29/2024 12:48:25 > 56ce77: INFO] IP: 169.254.133.2
[11/29/2024 12:48:25 > 56ce77: SYS INFO] Status changed to Success
[11/29/2024 12:48:25 > 56ce77: SYS INFO] Process went down, waiting for 60 seconds
[11/29/2024 12:48:25 > 56ce77: SYS INFO] Status changed to PendingRestart

一方 Kudu Bash

image.png

うーんやっぱり Kudu とは別のコンテナで実行されているのかな???

もう少し情報追加

#!/bin/sh
# this script log system info
cat /proc/self/cgroup
echo "whoami: $(whoami)"
echo "IP: $(ifconfig | grep inet | head -n 1 | awk '{print $2}')"
ps aux
echo "sleeping for 1000000 seconds"
sleep 1000000

image.png

なんか見覚えあるプロセスがいる。これはもしやアプリコンテナではなかろうか。。。
ということで、アプリコンテナ側で見てみると発見。

image.png

結論

何らかの仕組みを使ってアプリコンテナ内で実行されている。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?