Beispiel #1
0
func (a *Analyzer) FillServices(services *[]*common.Service) error {
	service := a.GetOrCreateWebService(services)
	service.Ports = []*common.PortMapping{common.NewPortMapping()}
	hasFoundServer, server := a.detectWebServer(service.Command)

	if service.Command == "" {
		if common.IsDjangoProject(a.RootDir) {
			service.Command = "python manage.py runserver"
			service.Ports[0].Container = "8000"
			a.Messages.Add("No command was defined for 'web' service so '" + service.Command + "' was assumed. NOTE: This is not *suitable* for production! Please define in your Procfile the command to run you production server.")
		} else {
			//TODO:
		}
	} else {
		var err error
		service.Ports[0].Container, err = a.FindPort(hasFoundServer, server, &service.Command)
		if err != nil {
			return err
		}
	}

	service.BuildCommand = a.AskForCommand("python manage.py migrate", "build")
	service.DeployCommand = a.AskForCommand("python manage.py migrate", "deployment")

	return nil
}
Beispiel #2
0
func (a *Analyzer) FillServices(services *[]*common.Service) error {
	service := a.GetOrCreateWebService(services)
	service.Ports = []*common.PortMapping{common.NewPortMapping()}
	isRails, _ := common.GetGemVersion(a.Gemfile, "rails")

	if service.Command == "" {
		if isRails {
			service.Command = "bundle exec rails server -e _env:RAILS_ENV"
			service.Ports[0].Container = "3000"
		} else {
			service.Command = "bundle exec rackup -E _env:RACK_ENV"
			service.Ports[0].Container = "9292"
		}
		a.Messages.Add("No command was defined for 'web' service so '" + service.Command + "' was assumed. Please make sure this is using a production server.")
	} else {
		var err error
		hasFoundServer, server := a.detectWebServer(service.Command)
		service.Ports[0].Container, err = a.FindPort(hasFoundServer, server, &service.Command)

		if err != nil {
			return err
		}
	}

	if isRails {
		service.BuildCommand = a.AskForCommand("/bin/sh -c \"RAILS_ENV=_env:RAILS_ENV bundle exec rake db:schema:load\"", "build")
		service.DeployCommand = a.AskForCommand("/bin/sh -c \"RAILS_ENV=_env:RAILS_ENV bundle exec rake db:migrate\"", "deployment")
	} else {
		service.BuildCommand = a.AskForCommand("", "build")
		service.DeployCommand = a.AskForCommand("", "deployment")
	}

	return nil
}