I am attempting to set up Supervisor to run a sample Vapor app written in Swift 5.8 on an Ubuntu 22.04 server (I have also tried on 20.4 with the same result). The app was created with vapor new hello -n
and runs fine with swift run App serve --hostname 0.0.0.0 --port 8080
.
I have copied the .conf file for Supervisor from the Vapor documentation and placed it at /etc/supervisor/conf.d/hello.conf. My username is also "vapor". The contents of the file are as follows:
[program:hello]
command=/home/vapor/hello/.build/release/Run serve --env production
directory=/home/vapor/hello/
user=vapor
stdout_logfile=/var/log/supervisor/%(program_name)-stdout.log
stderr_logfile=/var/log/supervisor/%(program_name)-stderr.log
I have verified that the path /home/vapor/hello/.build/release/ exists after running
swift build -c release --disable-sandbox --enable-test-discovery
. But there is no Run file.
Upon running:
supervisorctl reread
supervisorctl add hello
supervisorctl start hello
I receive the error message: hello: ERROR (no such file)
.
Running sudo supervisorctl status
provides the more detailed message:
FATAL can't find command '/home/vapor/hello/release/.build/Run'
.
Restarting Supervisor did not help. Does somebody knows what I am missing?
The Vapor app is using a new executable target, called App
. However supervisor is referring to a binary called Run
which doesn't exist, hence the error.
Change your supervisor config to
[program:hello]
command=/home/vapor/hello/.build/release/App serve --env production
directory=/home/vapor/hello/
user=vapor
stdout_logfile=/var/log/supervisor/%(program_name)-stdout.log
stderr_logfile=/var/log/supervisor/%(program_name)-stderr.log