I installed MailHog in my staging environment by following these steps:
sudo apt-get -y install golang-go
go get github.com/mailhog/MailHog
In order to manually start the service I do:
cd ~/go/bin
./MailHog
Since I'm using Laravel I already have supervisor
running for workers.
I'm wondering if there is a way to add a new .conf
file in order to start MailHog.
I tried to follow how Laravel workers are started, but so far no luck
[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
I get mailhog:mailhog_00: ERROR (no such file)
when I try to start supervisor.
I need a way to auto boot MailHog, no matter if I need supervisor or via services.
I'll really appreciate it if you can provide the "recipe" for starting MailHog from the supervisor or by using a service.
CodePudding user response:
You don't need a supervisor, you can use Linux systemd
to create a startup application.
systemd is the standard system and service manager in modern Linux. It is responsible for executing and managing programs during Linux startup
before that add mailhog to your system path variable to call it only by name
export PATH=$PATH:/home/YOUR-USERNAME/go/bin/MailHog
sudo systemctl enable mailhog
or if you are using any desktop environment , you can follow this https://askubuntu.com/questions/48321/how-do-i-start-applications-automatically-on-login
CodePudding user response:
I figure out how the complete installation/setup should be:
- Downloading & installation
sudo apt-get -y install golang-go
go get github.com/mailhog/MailHog
- Copy Mailhog to bin directory
sudo cp ~/go/bin/MailHog /usr/local/bin/Mailhog
- Create Mailhog service
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
- Check status service is loaded successfully.
sudo systemctl status mailhog
Output
mailhog.service - Mailhog
Loaded: loaded (/etc/systemd/system/mailhog.service; disabled; vendor preset: enabled)
Active: inactive (dead)
- Start service
sudo systemctl enable mailhog
- Reboot system and visit http://yourdomain.com:8025/