I'm trying to figure out how to deploy in IBM Bluemix a Cloudfoundry app that uses Vapor framework.
IBM is providing facilities and guidance for using his platform for developing server side Swift apps with his framework, Kitura. I think as a Cloudfoundry provider, with the proper Swift buildpack, we must be able to deploy generic server side Swift code.
Finally, while learning bits of CF, I reached the point that with the CloudFoundry CLI:
But when I load the page (https://sommobilitatcore.eu-gb.mybluemix.net/) I get:
404 Not Found: Requested route ('sommobilitatcore.eu-gb.mybluemix.net') does not exist.
Can anyone help me on that? Thanks!
Some context:
The manifest.yml:
applications:
- path: .
memory: 256M
instances: 1
name: SomMobilitatCore
disk_quota: 1024M
buildpack: https://github.com/IBM-Swift/swift-buildpack.git
The Procfile
web: App
(main.swift is in Source/App/)
No port is configured in Vapor Config files, then Vapor is trying to listen to port 80:
import Vapor
import HTTP
let drop = Droplet()
let _ = drop.config["app", "key"]?.string ?? ""
drop.get("/") { request in
return try drop.view.make("welcome.html")
}
(...)
let port = drop.config["app", "port"]?.int ?? 80
// Print what link to visit for default port
drop.serve()
UPDATE:
Finally get it working without Procfile, the manifest.yml
- path: .
instances: 1
memory: 256M
disk_quota: 1024M
name: SomMobilitat4
command: App --env=production --workdir="./"
buildpack: swift_buildpack
And the /Config/production/servers.json :
{
"production": {
"port": "$PORT"
}
}
I neither specify the port variable in the main.swift file. With the updated Vapor version:
import Vapor
import HTTP
let drop = Droplet()
drop.get("/") { request in
return "hello vapor in bluemix cloudfoundry"
}
drop.run()
If you are new to Cloudfoundry or IBM Bluemix, this is a way to work:
You signup in a Cloudfoundry provider (ex: bluemix)
You have you Vapor project locally.
Add to it a .cfignore file with this short line: Packages/ to avoid uploading Packages to the server.
Add to it the mentioned manifest.yml file.
Download and install the Cloudfoundry CLI: https://docs.cloudfoundry.org/cf-cli/
With the CLI:
cf api https://api.eu-gb.bluemix.net
cf login
cf push
A 404 error is an HTTP status code that means that the page you were trying to reach on a website couldn't be found on their server. 404 Not Found error messages are frequently customized by individual websites. You can see some of the more creative ones in our 20 Best 404 Error Pages Ever slideshow.
Microsoft IIS web servers sometimes give more specific information about the cause of 404 Not Found errors by suffixing a number after the 404, as in HTTP Error 404.3 - Not Found, which means MIME type restriction. Retry the web page by pressing F5, clicking/tapping the refresh/reload button, or trying the URL from the address bar again.
He writes troubleshooting content and is the General Manager of Lifewire. A 404 error is an HTTP status code that means that the page you were trying to reach on a website couldn't be found on their server . To be clear, the error indicates that while the server itself is reachable, the specific page showing the error is not.
PRODUCT DISCLOSURE $. A 404 error is an HTTP status code that means that the page you were trying to reach on a website couldn't be found on their server. To be clear, the 404 error indicates that while the server itself is reachable, the specific page showing the error is not.
To run a Vapor app on Bluemix:
Config
directory with servers.json
(use exactly these names). servers.json
should contain the following:
{ "myserver": { "port": "$PORT" } }
It will instruct Vapor to start a server named myserver
on the port taken from $PORT
environment variable used by Bluemix.
In your Procfile
, add --workDir=.
parameter, so it would contain:
web: App --workDir=.
It will instruct Vapor to look for Config
directory in the current directory during run time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With