Browse Source

rpicamera: print an error when libcamera is not found (#1585)

pull/1586/head
Alessandro Ros 3 years ago committed by GitHub
parent
commit
7e684f157d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 26
      internal/core/core.go
  2. 10
      internal/rpicamera/libcamera.go
  3. 3
      internal/rpicamera/libcamera_disabled.go

26
internal/core/core.go

@ -72,6 +72,7 @@ func New(args []string) (*Core, bool) { @@ -72,6 +72,7 @@ func New(args []string) (*Core, bool) {
if err != nil {
panic(err)
}
_, err = parser.Parse(args)
parser.FatalIfErrorf(err)
@ -80,15 +81,6 @@ func New(args []string) (*Core, bool) { @@ -80,15 +81,6 @@ func New(args []string) (*Core, bool) {
os.Exit(0)
}
// on Linux, try to raise the number of file descriptors that can be opened
// to allow the maximum possible number of clients
// do not check for errors
rlimit.Raise()
rpicamera.LibcameraSetup()
gin.SetMode(gin.ReleaseMode)
ctx, ctxCancel := context.WithCancel(context.Background())
p := &Core{
@ -212,9 +204,19 @@ func (p *Core) createResources(initial bool) error { @@ -212,9 +204,19 @@ func (p *Core) createResources(initial bool) error {
if !p.confFound {
p.Log(logger.Warn, "configuration file not found, using an empty configuration")
}
}
if initial {
// on Linux, try to raise the number of file descriptors that can be opened
// to allow the maximum possible number of clients
// do not check for errors
rlimit.Raise()
err := rpicamera.LibcameraSetup()
if err != nil {
return err
}
gin.SetMode(gin.ReleaseMode)
p.externalCmdPool = externalcmd.NewPool()
}
@ -672,7 +674,7 @@ func (p *Core) closeResources(newConf *conf.Conf, calledByAPI bool) { @@ -672,7 +674,7 @@ func (p *Core) closeResources(newConf *conf.Conf, calledByAPI bool) {
p.metrics = nil
}
if newConf == nil {
if newConf == nil && p.externalCmdPool != nil {
p.Log(logger.Info, "waiting for external commands")
p.externalCmdPool.Close()
}

10
internal/rpicamera/libcamera.go

@ -35,9 +35,13 @@ func setupSymlink(name string) error { @@ -35,9 +35,13 @@ func setupSymlink(name string) error {
}
// LibcameraSetup creates libcamera simlinks that are version agnostic.
func LibcameraSetup() {
setupSymlink("libcamera")
setupSymlink("libcamera-base")
func LibcameraSetup() error {
err := setupSymlink("libcamera")
if err != nil {
return err
}
return setupSymlink("libcamera-base")
}
// LibcameraCleanup removes files created by LibcameraSetup.

3
internal/rpicamera/libcamera_disabled.go

@ -4,7 +4,8 @@ @@ -4,7 +4,8 @@
package rpicamera
// LibcameraSetup creates libcamera simlinks that are version agnostic.
func LibcameraSetup() {
func LibcameraSetup() error {
return nil
}
// LibcameraCleanup removes files created by LibcameraSetup.

Loading…
Cancel
Save