0

我按照以下步骤在暂存环境中安装了 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 的“秘诀”,我将不胜感激。

4

2 回答 2

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/
于 2021-12-27T04:59:20.783 回答
0

您不需要主管,您可以使用 Linuxsystemd创建启动应用程序。

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

于 2021-12-27T02:47:32.153 回答