使用Mac M1时,命令`supervisorctl restart`执行失败,退出代码为…

huangapple go评论72阅读模式
英文:

Command `supervisorctl restart` failed with exit code using mac m1

问题

我正在运行在Mac M1上,使用Docker和Gulp。

我的第一个错误是"command ld not found",但我在这里解决了它。
https://stackoverflow.com/questions/71718772/how-to-solve-running-gcc-failed-exit-status-1-in-mac-m1

然后我遇到了这个错误。

完整的错误信息如下:

[17:09:04] 'restart-supervisor' 在 1.04 秒后出错

[17:14:45] '<anonymous>' 在 220 毫秒后出错

[17:14:45] 插件"gulp-shell"出错

错误信息:

    命令 `supervisorctl restart projectname` 执行失败,退出码为 7

[17:14:45] 'restart-supervisor' 在 838 毫秒后出错

我已经进行了很多研究:

  1. 我尝试了这个方法,但是命令找不到。
    https://github.com/Supervisor/supervisor/issues/121
  2. 还有这个方法。
    https://github.com/Supervisor/supervisor/issues/1223.
  3. 我甚至将我的镜像更改为 arm64v8/golang:1.17-alpine3.14

这是我的gulpfile.js文件:

var gulp = require("gulp");
var shell = require('gulp-shell');
gulp.task("build-binary", shell.task(
'go build'
));
gulp.task("restart-supervisor", gulp.series("build-binary", shell.task(
'supervisorctl restart projectname'
)))
gulp.task('watch', function() {
    gulp.watch([
                "*.go", 
                "*.mod", 
                "*.sum", 
                "**/*.go", 
                "**/*.mod",
                "**/*.sum"
                ], 
                {interval: 1000, usePolling: true},
                gulp.series('build-binary', 'restart-supervisor'
    ));
});
gulp.task('default', gulp.series('watch'));

这是我的当前dockerfile:

FROM arm64v8/golang:1.17-alpine3.14
RUN apk update && apk add gcc make git libc-dev binutils-gold

# 安装依赖
RUN apk add --update tzdata \
    --no-cache ca-certificates git wget \
    nodejs npm \
    g++ \
    supervisor \
    && update-ca-certificates \
    && npm install -g gulp gulp-shell

COPY ops/api/local/supervisor /etc
ENV PATH $PATH:/go/bin
WORKDIR /go/src/github.com/projectname/src/api

在我的docker-compose.yaml文件中,我有以下内容:

entrypoint:
  [
    "sh",
    "-c",
    "npm install gulp gulp-shell && supervisord -c /etc/supervisord.conf && gulp"
  ]

vim /etc/supervisord.conf:

    #!/bin/sh

[unix_http_server]
    file=/tmp/supervisor.sock
    username=admin
    password=revproxy
    
    [supervisord]
    nodaemon=false
    user=root
    logfile=/dev/null
    logfile_maxbytes=0
    logfile_backups=0
    loglevel=info   
    [rpcinterface:supervisor]
    supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
    
    [supervisorctl]
    serverurl=unix:///tmp/supervisor.sock
    username=admin
    password=revproxy
    
    [program:projectname_api]
    directory=/go/src/github.com/projectname/src/api
    command=/go/src/github.com/projectname/src/api/api
    autostart=true
    autorestart=true
    stderr_logfile=/go/src/github.com/projectname/src/api/api_err.log
    stderr_logfile_maxbytes=0
  stdout_logfile=/go/src/github.com/projectname/src/api/api_debug.log
    stdout_logfile_maxbytes=0
    startsecs=0

但是,说真的,这个Mac M1有什么问题。
我已经尝试在Rosetta和非Rosetta上进行,版本为2。
如果我的问题标题有误,请纠正我,我也不确定我的错误是什么。

英文:

I am running on mac m1, docker, gulp.

my first error was command ld not found, but i fixed it in here.
https://stackoverflow.com/questions/71718772/how-to-solve-running-gcc-failed-exist-status-1-in-mac-m1

After that it leads me to this error.

this is the full error:

[17:09:04] &#39;restart-supervisor&#39; errored after 1.04 s

[17:14:45] &#39;&lt;anonymous&gt;&#39; errored after 220 ms

[17:14:45] Error in plugin &quot;gulp-shell&quot;

Message:

    Command `supervisorctl restart projectname` failed with exit code 7

[17:14:45] &#39;restart-supervisor&#39; errored after 838 ms

Ive done a lot of research:

  1. Ive tried doing this, but the command isn't found.
    https://github.com/Supervisor/supervisor/issues/121
  2. This as well.
    https://github.com/Supervisor/supervisor/issues/1223.
  3. I even change my image to arm64v8/golang:1.17-alpine3.14

this is my gulpfile.js:

var gulp = require(&quot;gulp&quot;);
var shell = require(&#39;gulp-shell&#39;);
gulp.task(&quot;build-binary&quot;, shell.task(
&#39;go build&#39;
));
gulp.task(&quot;restart-supervisor&quot;, gulp.series(&quot;build-binary&quot;, shell.task(
&#39;supervisorctl restart projectname&#39;
)))
gulp.task(&#39;watch&#39;, function() {
    gulp.watch([
                &quot;*.go&quot;, 
                &quot;*.mod&quot;, 
                &quot;*.sum&quot;, 
                &quot;**/*.go&quot;, 
                &quot;**/*.mod&quot;,
                &quot;**/*.sum&quot;
                ], 
                {interval: 1000, usePolling: true},
                gulp.series(&#39;build-binary&#39;, &#39;restart-supervisor&#39;
    ));
});
gulp.task(&#39;default&#39;, gulp.series(&#39;watch&#39;));

This is my current dockerfile:

FROM arm64v8/golang:1.17-alpine3.14
RUN apk update &amp;&amp; apk add gcc make git libc-dev binutils-gold

# Install dependencies
RUN apk add --update tzdata \
    --no-cache ca-certificates git wget \
    nodejs npm \
    g++ \
    supervisor \
    &amp;&amp; update-ca-certificates \
    &amp;&amp; npm install -g gulp gulp-shell

COPY ops/api/local/supervisor /etc
ENV PATH $PATH:/go/bin
WORKDIR /go/src/github.com/projectname/src/api

in my docker-compose.yaml i have this:

entrypoint:
  [
    &quot;sh&quot;,
    &quot;-c&quot;,
    &quot;npm install gulp gulp-shell &amp;&amp; supervisord -c /etc/supervisord.conf &amp;&amp; gulp&quot;
  ]

vim /etc/supervisord.conf:

    #!/bin/sh

[unix_http_server]
    file=/tmp/supervisor.sock
    username=admin
    password=revproxy
    
    [supervisord]
    nodaemon=false
    user=root
    logfile=/dev/null
    logfile_maxbytes=0
    logfile_backups=0
    loglevel=info   
    [rpcinterface:supervisor]
    supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
    
    [supervisorctl]
    serverurl=unix:///tmp/supervisor.sock
    username=admin
    password=revproxy
    
    [program:projectname_api]
    directory=/go/src/github.com/projectname/src/api
    command=/go/src/github.com/projectname/src/api/api
    autostart=true
    autorestart=true
    stderr_logfile=/go/src/github.com/projectname/src/api/api_err.log
    stderr_logfile_maxbytes=0
  stdout_logfile=/go/src/github.com/projectname/src/api/api_debug.log
    stdout_logfile_maxbytes=0
    startsecs=0

But seriously, what is wrong with this mac m1.
I have tried doing it in rosetta and non-rosetta, version 2.
If the title of my question is wrong please correct me, I also not sure of my error.

答案1

得分: 0

我通过添加 #!/bin/shstartsecs=0 来解决了问题,没有显示任何错误,但下一个问题是 API 没有在运行。

英文:

I fixed the problem by adding #!/bin/sh and startsecs=0, no errors to be showing but the next problem is the API is not running.

huangapple
  • 本文由 发表于 2022年4月7日 01:29:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/71771233.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定