| 154 | } |
| 155 | |
| 156 | func init_(ctx context.Context, data, config types.SM, driveUtils drive_util.DriveUtils) error { |
| 157 | cfg, e := driveUtils.Data.Load("_script") |
| 158 | if e != nil { |
| 159 | return e |
| 160 | } |
| 161 | if cfg["_script"] != "" { |
| 162 | // _script is not modifiable |
| 163 | delete(data, "_script") |
| 164 | } else if data["_script"] != "" { |
| 165 | cfg["_script"] = data["_script"] |
| 166 | if e := driveUtils.Data.Save(types.SM{"_script": data["_script"]}); e != nil { |
| 167 | return e |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | vm, e := createVm(ctx, driveUtils.Config, cfg["_script"]) |
| 172 | if e != nil { |
| 173 | return e |
| 174 | } |
| 175 | defer func() { _ = vm.Dispose() }() |
| 176 | |
| 177 | initConfigVal, e := vm.GetValue("__driveInit") |
| 178 | if e != nil { |
| 179 | return e |
| 180 | } |
| 181 | if initConfigVal.IsNil() { |
| 182 | return nil |
| 183 | } |
| 184 | |
| 185 | _, e = vm.Call(ctx, "__driveInit", s.NewContext(vm, ctx), data, config, newScriptDriveUtils(driveUtils)) |
| 186 | return e |
| 187 | } |
| 188 | |
| 189 | // parsePoolConfig parses config like this: MaxTotal,MaxIdle,MinIdle,IdleTime |
| 190 | func parsePoolConfig(arg string) (*s.VMPoolConfig, error) { |