Answer the question
In order to leave comments, you need to log in
How to inject golang/beego into autoload (systemd, upstart, supervisor) vps linux?
Hello everyone, tell me who knows. I installed golang, everything works fine and the beego application starts up, I tried to add it to autoload according to various tutorials, including in Japanese, I wrote the following
upstart
description "A stupid golang http listener"
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
setuid www-data
setgid www-data
respawn
respawn limit 5 2
exec /root/home/src/hello/hello
[Unit]
Description=Webhook
[Service]
User=deployer
Group=www-data
Restart=on-failure
ExecStart=/root/home/src/hello/hello
[Install]
WantedBy=multi-user.target
[program:yourapp]
command=/root/home/src/hello/hello # the location of your app
autostart=true
autorestart=true
startretries=10
user=yourappuser # the user your app should run as (i.e. *not* root!)
directory=/ root/home/src/hello/ # where your application runs from
environment=APP_SETTINGS="/srv/www/yourapp.com/prod.toml" # environmental variables
redirect_stderr=true
stdout_logfile=/var/log/supervisor/yourapp.log # the name of the log file.
stdout_logfile_maxbytes=50MB
stdout_logfile_backups=10
Answer the question
In order to leave comments, you need to log in
for systemd
unit:
$ systemctl --user cat test.service
# /home/admin/.config/systemd/user/test.service
[Unit]
After=local-fs.target network.target
[Service]
Type=simple
ExecStart=/home/admin/code/go/bin/test
Restart=on-failure
RestartSec=60
TimeoutSec=60
[Install]
WantedBy=default.target
$ systemctl --user enable test.service
$ systemctl --user start test.service
# loginctl enable-linger <username>
Совсем недавно сделал так:
https://elithrar.github.io/article/running-go-appl...
did everything as you wrote, in your case, I got the following message
Failed to get D-Bus connection: Connection refused
I also tried this tutorial
in this case, the console writes the following
[email protected]:/opt# service listener status
● listener.service - Webhook
Loaded: loaded (/etc/systemd/system/listener.service; enabled)
Active: failed (Result: start-limit) since Fri 2016-08-26 20:46:12 EDT; 6s ago
Process: 4536 ExecStart=/opt/listen (code=exited, status=217/USER)
Main PID: 4536 (code=exited, status=217/USER)
Aug 26 20:46:12 free systemd[1]: Unit listener.service entered failed state.
Aug 26 20:46:12 free systemd[1]: listener.service holdoff time over, sche...t.
Aug 26 20:46:12 free systemd[1]: Stopping Webhook...
Aug 26 20:46:12 free systemd[1]: Starting Webhook...
Aug 26 20:46:12 free systemd[1]: listener.service start request repeated ...t.
Aug 26 20:46:12 free systemd[1]: Failed to start Webhook.
Aug 26 20:46:12 free systemd[1]: Unit listener.service entered failed state.
Hint: Some lines were ellipsized, use -l to show in full.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question