【问题标题】:Auto boot MailHog on Ubuntu 20.04在 Ubuntu 20.04 上自动启动 MailHog
【发布时间】:2022-01-26 03:43:20
【问题描述】:

我按照以下步骤在暂存环境中安装了 MailHog:

  1. sudo apt-get -y install golang-go
  2. go get github.com/mailhog/MailHog

为了手动启动我做的服务:

  1. cd ~/go/bin
  2. ./MailHog

由于我使用的是 Laravel,我已经有 supervisor 为工人运行。 我想知道是否有办法添加一个新的.conf 文件以启动 MailHog。

我试图了解 Laravel 工人的启动方式,但到目前为止还没有成功

[program:mailhog]
process_name=%(program_name)s_%(process_num)02d
command=~/go/bin/MailHog
user=ubuntu
stdout_logfile=/var/www/api/storage/logs/mailhog.log

当我尝试启动主管时,我得到mailhog:mailhog_00: ERROR (no such file)

我需要一种自动启动 MailHog 的方法,无论我需要主管还是通过服务。

如果您能从主管或使用服务提供启动 MailHog 的“配方”,我将不胜感激。

【问题讨论】:

    标签: laravel supervisord ubuntu-20.04 mailhog


    【解决方案1】:

    我知道完整的安装/设置应该如何:

    1. 下载和安装
    sudo apt-get -y install golang-go
    go get github.com/mailhog/MailHog
    
    1. 将 Mailhog 复制到 bin 目录
    sudo cp ~/go/bin/MailHog /usr/local/bin/Mailhog
    
    1. 创建 Mailhog 服务
    sudo tee /etc/systemd/system/mailhog.service <<EOL
    [Unit]
    Description=Mailhog
    After=network.target
    [Service]
    User=ubuntu 
    ExecStart=/usr/bin/env /usr/local/bin/Mailhog > /dev/null 2>&1 &
    [Install]
    WantedBy=multi-user.target
    EOL
    
    1. 检查状态服务已成功加载。
    sudo systemctl status mailhog
    

    输出

    mailhog.service - Mailhog
         Loaded: loaded (/etc/systemd/system/mailhog.service; disabled; vendor preset: enabled)
         Active: inactive (dead)
    
    1. 启动服务
    sudo systemctl enable mailhog
    
    1. 重启系统并访问http://yourdomain.com:8025/

    【讨论】:

      【解决方案2】:

      你不需要管理员,你可以使用 Linux systemd 来创建一个启动应用程序。

      systemd 是现代 Linux 中的标准系统和服务管理器。它负责在Linux启动期间执行和管理程序

      在此之前将 mailhog 添加到您的系统路径变量以仅按名称调用它

      export PATH=$PATH:/home/YOUR-USERNAME/go/bin/MailHog

      sudo systemctl enable mailhog

      或者如果你使用任何桌面环境,你可以按照这个 https://askubuntu.com/questions/48321/how-do-i-start-applications-automatically-on-login

      【讨论】:

        猜你喜欢
        • 2020-12-18
        • 1970-01-01
        • 2020-08-12
        • 2021-05-31
        • 1970-01-01
        • 2020-12-17
        • 1970-01-01
        • 2021-04-28
        • 2021-03-28
        相关资源
        最近更新 更多